Prev | Current Page 1007 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"


The frames of a sequence can be set manually, one at a time, using the setFrame method.
var frame : Rect = new Rect( 0, 0, 16, 16 );
var group : Int = 0;
var location : Int = 0;
sprite.setFrame( frame, group, location );
Figure 19-3
Part III: Extending the Possibilities
548
Here, the frame parameter is a Rect object representing the location and size of the image within the
sprite sheet.
The second parameter, group , represents the sequence of animation. For example, within a single sprite
sheet, we might have fifteen different sequences, whereby my character will perform different moves.
A group is just that; a single sequence of frames representing a single move, topic, or other such related
behavior.
Finally, the location parameter. This is merely the position in the group array that the frame should
appear. Normally this would be the position after the last frame that already exists in the group , but can
vary, particularly if you are replacing a frame.
An example of frames being added for the bat character of the previous code might look like this.


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