HTML and CSS Reference
In-Depth Information
Chapter 16
Getting Animated
What's in This Chapter?
• Defining an animation API
• Building an animation system
• Creating a Canvas-based viewport
• Creating parallax backgrounds Code Downloads for this Chapter
The code downloads for this chapter are found at
title.cgi?isbn=9781118301326 on the Download Code tab. The code is in the chapter 16 download and individu-
ally named according to the names throughout the chapter.
The spritesheet support from Chapter 11, “Bootstrapping the Quintus Engine: Part III,” allowed Sprites with
spritesheets to play back animations by modifying the frame property of a sprite. Although this approach works
for simple games with single animations, more complicated games such as the platformer built in Chapter 18,
“Creating a 2-D Platformer,” require a more robust system to handle animation. This chapter builds an animation
system that enables more complex behaviors. This chapter also examines what you need to build and animate
Canvas-based parallax scrolling backgrounds.
Building Animation Maps
A robust animation system for Quintus should have two main goals. The first goal is to make it easy to trigger
animations by name and not have to worry about the speed or the frame that the animation is playing at. The
second goal is to have the animation system hook into the entity's events so that animations can trigger events to
make it easier to time actions and behaviors.
Deciding on an Animation API
To begin, think about what a good API for an animation system might look like. There are two main pieces to
consider. The first is the method to define animation. The second is the way animations are played. The first is
Search WWH ::

Custom Search