Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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!

share|improve this question

4 Answers 4

up vote 5 down vote accepted

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.

share|improve this answer

Can't you associate an explosion sprite to your boss and play it when your Boss_HP == 0?

share|improve this answer

Android provides an Animation API that allows you to manipulate the properties of an object on the screen over a time interval. See http://developer.android.com/reference/android/animation/package-summary.html for a description of the API and http://www.vogella.com/articles/AndroidAnimation/article.html for a good tutorial.

share|improve this answer

It's probably not the most elegant thing in the world, but I accomplish this in the game by making a simple conditional.

if (enemy.isDead() && enemy.getCurrentFrame() == enemy.numberOfFrames())
     //Remove enemy

I'm sure there are better ways to do this, but this gets the job done for me with minimal effort.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.