The size of each frame, and indeed, the
height of each row of frames, is depicted with the spriteWidth and spriteHeight parameters. Once
all frames have been calculated, they are stored in the given group location.
One point to notice with regard to the setFrameRange method is that it doesn ??™ t expect any empty space
to exist between frames, either horizontally or vertically. This, however, may change with future version
of NME.
Chapter 19: Multimedia with Neko
549
Animating Sprites
Animating the Sprite object actually makes drawing to a Surface a lot easier. Providing you have
all of your frame locations calculated, you can begin rendering your animation with a simple call to
the animate method. This method, unlike the draw method of the Surface class, accepts a single
parameter: a Timer instance. The Timer is used to calculate when the next frame in a given sequence
should be rendered.
Alongside the animate method, you can also choose how your animation should flow. Like animate,
choosing the sequence that your frames are rendered is incredibly simple, and is carried out by setting a
type parameter of the Sprite class using an AnimType enumerator.
Pages:
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021