Prev | Current Page 1006 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

It ??™ s all possible.
A sprite is normally a representation of one or more images that form an animated character. This series
of animation frames usually derives from a single image, or sprite sheet . The sprite sheet displays a
number of frames in a grid with each frame being of the same size for each animation sequence.
Figure 19 - 3 depicts a typical sprite sheet, courtesy of Ari Feldman ( www.flyingyogi.com ).
Chapter 19: Multimedia with Neko
547
Acquiring a Sprite from a Sprite Sheet
By far the easiest, and probably the least memory hungry way of using a sprite sheet is to load the
entire sheet into memory, then display only the segment you wish to show at any one time. This
will give the impression of swapping frames from many images, while only having to keep track of
one image.
The NME library performs this task by storing the coordinates of each frame as an array of four integer
values stored in an object that represents the rectangle of pixels to display. This array is further broken
down into an array of animation sequences, as a sprite sheet will often represent more than a single
sequence.


Pages:
994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018