animation_done Message From Animated Sprite Created by Factory? [SOLVED]

Hi, all! Newbie question for you:

If I instantiate a game object via a factory (i.e. factory.create())— is an ‘animation_done’ message sent at the end of the sprite’s animation even though it’s not being played with an ‘animation_play’ message?

I’m creating an animated explosion sprite after two GO’s collide, and I need to remove the explosion after its animation is complete…

Thanks!
Bryan

I tested this. animation_done messages are only sent when you have used play_animation to start the animation. So use play_animation on init for the same default animation and you’ll then be able to get the animation_done message when it’s complete.

2 Likes

Ah, that makes sense. I’ll give it a go!

Thanks,
Bryan

Problem solved! I created a default animation for my explosion sprite that just consists of the first frame of the explosion animation and set it to not play. I then create the explosion via my ‘explosion factory’, which then triggers a ‘play_animation’ message in the explosion’s ‘init’ function, which I have set to the full explosion animation. Then, in the explosion script’s ‘on_message’ function, I delete the explosion object when the ‘animation_done’ message is received.

Thanks, Pkeod! (btw, I bought your book yesterday. :slight_smile: )

Bryan

5 Likes