Using frame-based animation
Specifying multiple images (frames) is very common and in many cases, the most realistic way to animate your game objects. So we will start this chapter by speaking about frame-based animation.
Frame-based animation is quite simple from a developer's point of view. You just have multiple images that are called frames, where each frame depicts your game object at some point in time during the animation. For example, if you shoot an arrow, you might have the following frames:
In the preceding image, frame 1 is our initial frame with the arrow still in the bow. We use this frame as a still image when aiming. In frame 2, the arrow is shot and disappears from the hunter's game object as it is now a separate object. Frames 3 to 6 depict the hunter taking another arrow and putting it in the bow. Then we return to frame 1 and it looks like the hunter tenses the bow (when we go from frame 6 to frame 1).
This way we get a...