Animation states - Changing and Rotating between

I’m hacking my way through the Corona SDK and really enjoying myself. Could someone offer some advice on managing sprite animations and rotating through different animations while waiting for an existing animation to finish?

I know there are event states you can watch for but I haven’t seen an example of anyone else doing something similiar with an animated sprite. I’m sure I’m just missing something :slight_smile:

I have a sprite playing an idle animation and I then want to play an attack animation, when it is finished I want it to play a hurt animation on the second character and the 1st character go back to an idle animation. When the hurt animation is finished I want character 2 to go back to idle, etc.

Does someone have a chunk of code to manage sprite animation states like that?

On this same topic, I’m playing around with the sprite eventlisteners and making a little progress. I don’t see a way to see what sprite is calling the event listener though. For example, I’d like to use the same eventlistener for a player1 and player2 character but I can’t see a way to see which sprite threw the event

It sounds like to me that while your idle animation on the hero, you have to do some action to initiate the attack, be it a button, screen tap or some such. The handler for that action (button handler, tap handler, etc) would play the attack animation. Its not likely that your attack animation will always result in the target being it. You probably will need another listener of sorts, such as a collision detection listener. When you detect that the attack was successful, however that happens, then you would play the hurt animation on the target sprite.

Then for the hero’s attack back to idle, you can wait for the attack animation’s onComplete event to play the hero’s idle animation. When the hurt animation finishes, you can use its onComplete event to play the target’s idle animation.

Rob

On this same topic, I’m playing around with the sprite eventlisteners and making a little progress. I don’t see a way to see what sprite is calling the event listener though. For example, I’d like to use the same eventlistener for a player1 and player2 character but I can’t see a way to see which sprite threw the event

It sounds like to me that while your idle animation on the hero, you have to do some action to initiate the attack, be it a button, screen tap or some such. The handler for that action (button handler, tap handler, etc) would play the attack animation. Its not likely that your attack animation will always result in the target being it. You probably will need another listener of sorts, such as a collision detection listener. When you detect that the attack was successful, however that happens, then you would play the hurt animation on the target sprite.

Then for the hero’s attack back to idle, you can wait for the attack animation’s onComplete event to play the hero’s idle animation. When the hurt animation finishes, you can use its onComplete event to play the target’s idle animation.

Rob