Fix laser cooldown bug

This commit is contained in:
Raymond Xu
2021-01-18 19:35:37 -06:00
parent ac605c9982
commit 75f0073b47
5 changed files with 15 additions and 10 deletions

View File

@@ -60,9 +60,10 @@ class Hero extends GameObject {
let id = setInterval(() => { let id = setInterval(() => {
if (this.cooldown > 0) { if (this.cooldown > 0) {
this.cooldown -= 100; this.cooldown -= 100;
} else { if(this.cooldown === 0) {
clearInterval(id); clearInterval(id);
} }
}
}, 200); }, 200);
} }
canFire() { canFire() {

View File

@@ -60,9 +60,10 @@ class Hero extends GameObject {
let id = setInterval(() => { let id = setInterval(() => {
if (this.cooldown > 0) { if (this.cooldown > 0) {
this.cooldown -= 100; this.cooldown -= 100;
} else { if(this.cooldown === 0) {
clearInterval(id); clearInterval(id);
} }
}
}, 200); }, 200);
} }
canFire() { canFire() {

View File

@@ -58,9 +58,10 @@ class Hero extends GameObject {
let id = setInterval(() => { let id = setInterval(() => {
if (this.cooldown > 0) { if (this.cooldown > 0) {
this.cooldown -= 100; this.cooldown -= 100;
} else { if(this.cooldown === 0) {
clearInterval(id); clearInterval(id);
} }
}
}, 200); }, 200);
} }
canFire() { canFire() {

View File

@@ -65,9 +65,10 @@ class Hero extends GameObject {
let id = setInterval(() => { let id = setInterval(() => {
if (this.cooldown > 0) { if (this.cooldown > 0) {
this.cooldown -= 100; this.cooldown -= 100;
} else { if(this.cooldown === 0) {
clearInterval(id); clearInterval(id);
} }
}
}, 200); }, 200);
} }
canFire() { canFire() {

View File

@@ -60,9 +60,10 @@ class Hero extends GameObject {
let id = setInterval(() => { let id = setInterval(() => {
if (this.cooldown > 0) { if (this.cooldown > 0) {
this.cooldown -= 100; this.cooldown -= 100;
} else { if(this.cooldown === 0) {
clearInterval(id); clearInterval(id);
} }
}
}, 200); }, 200);
} }
canFire() { canFire() {