O'Reilly logo

Android Game Programming by Example by John Horton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Animating Bob

Sprite sheet animations work by quickly changing the image drawn to the screen. Exactly like a child may draw the phases of a stick-man moving on the corner of a book, and then quickly flicking through it to make it appear to move.

The frames of Bob's animation are already contained within the player.png file we have been using to represent him.

Animating Bob

All we need to do is loop through them one at a time when the player is moving.

This is quite straightforward to implement. We will make a simple animation class that handles the function of keeping time and returning the appropriate part of the sprite sheet when requested. We can then initialize ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required