Character animation


(me_19) #1

Hallo every body, I have a question related to character animation: I am developing a platformer fighting game with FlashPunk an so far everything works well except for the character animation part. The problem can be resume as follow:

  • I want my character to do a certain attack when a certain key is clicked. So far the attack is only executed when the key is held down, once the key is relased, the animation stops right away. In any fighting game you find at the world wide web, hitting a key once is all that it is needed for a particular animation to play till that animation is finished. I try several approaches but none seems to work, I even followed the tutorials found at the flashpunk site but that does not the trick for me. Since I am new at as3 and flashpunk I was thinking that this may have to do with tweening, but I am not sure

Thanks for your help in advance!!!


(Alex Larioza) #2

Posting relevant code would be very helpful :smile:

However, I have a feeling you have an animation set to play when a button is being held down and when it is not. As a result, as soon as you let go of the key, the “idle” animation instantly plays. The idea here is to not tell the spritemap to play the idle animation until any previous animations have completed. Here’s an example:

If (Input.Check(Key.Z))
{
    spritemap.play("attack");
}
else
{
    if (spritemap.complete) // if the last animation is complete
    {
        spritemap.play("idle");
    }
} 

(me_19) #3

Thank you very much for your help! It really does sound very logic, I will definitely try that out.


(me_19) #4

Soon I will be posting the corresponding part of the code


(Zachary Lewis) #5

I’d also recommend using Input.pressed() over Input.check(). If the user holds the key down, he shouldn’t punching forever.