Game Development Reference
In-Depth Information
The setup
As we established earlier, the traditional approach involves a set of images that need to
change over time. For our example, we will use a crystal, which rotates around its centre.
Typically, an animation is kept in a single file (a sprite sheet ), where each frame of the an-
imation is stored, and in most cases, each frame is the same sizeā€”the size of the object. In
our example, the sprite is, 32 x 32 pixels and has eight frames, which play for one second.
Here is what the sprite sheet looks like:
The following screenshot shows our animation setup in code:
First of all, note that we are using the AssetManager class (from Chapter 2 , Loading
and using textures ) to load our sprite sheet. The next line sets the texture rectangle of the
sprite to target the first image in our sprite sheet. Here is what this means in terms of the
sprite sheet texture :
Search WWH ::




Custom Search