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…
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.
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. )