Game Development Reference
In-Depth Information
FIG 3.4 Half of a walk cycle where
the other half would be a reversal
of the arm and leg positions.
The animation images for a sprite are drawn based on the movement cycles
originally developed for cartoon characters. Preston Blair, an acclaimed
animator who worked for Disney, Warner Bros., and Hanna-Barbera, published
many illustrations demonstrating various character poses through a series of
movement cycles. Some of them can be found at http://www.animationarchive
.org/pics/pbanimation26-big.jpg . The first of these cycles often referred to when
teaching elementary animation is the walk cycle shown in Figure 3.4 . Note in
the walk cycle here, and the others by Preston Blair, the use of motion arcs for
natural movement. The character rises and falls with each step.
Each of the images in Figure 3.4 becomes a single frame for the sprite.
When these frames are cycled through in the game it gives the illusion
of a walking character.
Unity Hands On
Creating a Texture Atlas with Code and Animated Sprite
Step 1. Create a new Unity project.
Step 2. Create a new Shader called Sprite and copy the code from
Listing 3.1 .
Step 3. Add a plane into the Scene and orientate it such that the
visible side faces the camera.
Step 4. Download Chapter Three/walkcycles.zip from the Web site.
Unzip the file and add all the images into the Project.
Step 5. Create a new JavaScript file called AnimatedSprite and add
the code shown in Listing 3.3 .
Listing 3.3 Script to Build a Texture Atlas from a Series
of Single Images
var textures: Texture2D[];
var atlas: Texture2D;
var framerate: float = 15.0;
private var currentFrame = 0;
private var totalWidth:float;
Search Nedrilad ::




Custom Search