I'm making a game and basically I'm having some errors with the animation state.
public function movementChar()
{
if (touchingGround)
{
if (rightKey)
{
gotoAndStop("run");
scaleX = 1;
}
if (leftKey)
{
gotoAndStop("run");
scaleX = -1;
}
if (upKey)
{
gotoAndStop("jump");
this.y -= 15;
//touchingGround = false;
}
if (attackKey)
{
gotoAndStop("attack");
}
if (!rightKey && !leftKey && !upKey && !attackKey)
{
gotoAndStop("stop");
}
}
}
I have some other coding which says if the player is touching the ground then touchingGround = true;
and if it is true then the player can move right, left, jump and attack.
The problem is that when I press the attack key, it keeps on looping the animation and attacking.
I want the attack key to play the animation once and make the boolean hasAttacked = true; once.
Another problem is that when the player is moving and the attack key has been pressed/ hold down the animation freezes. Flash gets confused on which animation to play so it stops at frame 1 and glitches.
I would appreciate it if someone can give me an idea on how to fix this.
Thank you.