I would create two classes. One is the
Player class that defines what your player is doing. For example:
1
| enum Action {NA, LEFT, RIGHT, JUMP}; |
Then second, you have the
PlayerSprite class which renders the player on the screen. You could do it as described: have an array of images for each type of actions:
1 2 3 4
| Action action = player.getAction(); if (action == Action.LEFT) { } |
The
Player class doesn't know anything about images. It just purely contains the player information. The
PlayerSprite will need a timer to identify the correct image (in the series) to render it onto the screen.