Im creating a game, and found some problem, see Line 4, i declare attackFrame variable, means when its in attack mode, the frame change into this sequence, and in line 15 I change it back to normal frame, But after this step, when it go back into attack mode again, the frame is 28. It won't change into the attack frame sequence. why ?, anybody can help me ?, Thank you very much
attackMode:function(isFight)
{
if (isFight) {
var attackFrame = [33, 33, 34, 34, 35, 35];
this.frame = attackFrame;
if (game.frame % attackFrame.length === 0) {
this.hp--;
if (this.hp < 1) {
group.removeChild(this);
tower.splice(tower.indexOf(this), 1);
} else {
this.attackMode(false);
}
}
} else {
this.frame = 28;
}
}
In this case you need to put a square bracket on that
this.frame = 28;
to:
this.frame = [28];