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

Get Android: Game Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.