Game Development Reference
In-Depth Information
Animating Sprites
In the last few chapters, we managed to get the basics of our game out of the way—
we already have an infinite scrolling background, we handle collision detection with
the physics engine, and we already have established controls. How can we improve
our game? Of course, it can be enhanced with animation.
Our character does not move his legs while running, and that is clearly not the way it
should be. In this chapter, we are going to add animations to our character—he will
animate when he is running and jumping. We will also learn about texture atlases
and how to efficiently animate our game.
What is animation?
In order to achieve the desired effect of animating our character, we need to
understand a little more about animation. Behind the scenes, we will be showing
a rapid succession of images, which gives the illusion of movement. This is exactly
what we are going to do.
Animation is an easy way to add life to your game, to make it look nice and
engaging. We are going to use animation actions in order to run animations on
our character. An easy way to do this is by simply adding animation frames to
some array, feeding it to an action, and instructing the character sprite to run it
as shown in the following figure:
Changing the animation frames creates an illusion of movement
 
Search WWH ::




Custom Search