Having trouble with a game
I'm having trouble trying to get the enemy character in a game to attack once and then over again. Right now it's not going through the whole attack animation. If anyone has any ideas that would be great. the site is here:
and heres the code
//in an enemy attack function-
if (Math.abs(this.x - thePlayerX) < 80 && Math.abs(this.y - thePlayerY) < 20) {
EnemySpeed = 0;
if(Math.round(Math.random()*enemyHitDiff) == 1)
{
attack = true;
enemyFight();
}else attack = false;
private function enemyFight(){
if ((attack == true)&&(faceLeft == true)) {
animstep += 1;
if (animstep > attackLeftAnimation.length-1) {
animstep = 0;
}
gotoAndPlay(attackLeftAnimation[(animstep)]);
if(attackLeftAnimation[(animstep)]>14){
attack = false;
}
}else if ((attack == true)&&(faceRight == true)) {
animstep += 1;
if (animstep > attackRightAnimation.length) {
animstep = 0;
}
gotoAndPlay(attackRightAnimation[(animstep)]);
if(attackRightAnimation[(animstep)]>14){
attack = false;
}
}
}
Thank you