Playing a death anim on an enemy that I want to remove

I’ve been trying to find a tutorial on how to best make animations in Android. I already have some animations for my enemies and my character that are controlled by rectangles and changing rectangleframe between updates using a picture like this:

enter image description here

When I’m shooting my enemies they lose HP, and when their HP == 0 they get removed. As long as I’m using an arrayList (which I do for all enemies and bullets) I’m fine, since I can just use list.remove(i). But when I’m on a boss-level and the Boss’s HP == 0, I want to remove him and play an animation of an explosion of stars before the “End-screen”. Is there a preferred way to do temporary animations like this?

If you can give me an example or redirect me to a tutorial, I’d be really grateful!

Answer

You could have a special kind of entity that plays an animation right upon creation, and auto-deletes when done with it. Just spawn it when you boss’ health reaches 0.

Attribution
Source : Link , Question Author : Green_qaue , Answer Author : Laurent Couvidou

Leave a Comment