Game Development Reference
In-Depth Information
Animating Sprites
For most 2D games, animation is based on the principles of traditional flipbook
animation: a series of static 2D images are played in rapid succession to create an
illusion of motion (see Figure 2.4 ). For smooth animation, typically a minimum
of 24 FPS is required, which is the traditional frame rate that is used in film. This
means that for every one second of animation, you need 24 individual images.
Some genres, such as 2D fighting games, may use 60 FPS animations, which in-
creases the required number of images dramatically.
Figure 2.4 Animated run cycle.
A typical approach is to have an array of images that represents all the possible
statesofaparticularcharacter,regardlessoftheparticularanimation.Forexample,
a character that has both a walk and run cycle, each ten frames in length, would
have an array of 20 images in total. To keep things simple, these images would be
stored sequentially, which would mean frames 0-9 would correspond to the walk
cycle and frames 10-19 would correspond to the run cycle.
But this means we need some way to specify which frames correspond to which
animations. A simple way to encapsulate this animation frame information is to
create an AnimFrameData structure that specifies the start frame and number of
frames for one particular animation:
Click here to view code image
struct AnimFrameData
// The index of the first frame of an animation
Search WWH ::




Custom Search