bat.setFrame( new Rect(24, 63, 65, 44), 0, 0 );
bat.setFrame( new Rect(156, 63, 65, 44), 0, 1 );
bat.setFrame( new Rect(288, 63, 65, 44), 0, 2 );
bat.setFrame( new Rect(420, 63, 65, 44), 0, 3 );
As you can see, here the images are defined for the locations 0 through 3 of group 0.
An alternative, and indeed, a much quicker option, is to use the setFrameRange method.
var xOffset : Int = 0;
var yOffset : Int = 0;
var sprWidth : Int = 16;
var sprHeight : Int = 16;
var columns : Int = 6;
var count : Int = 20;
var group : Int = 0;
srf.setFrameRange( xOffset, yOffset, sprWidth, sprHeight, columns, count, group );
This method performs the task of adding multiple frames at once to a group, by defining the start
location of the frame range on the sprite sheet with the xOffset and yOffset parameters, then bit by
bit, iterating through each frame until count frames have been added. The setFrameRange method
continues horizontally across the sprite sheet until it has added frames to a multiple of the cols
parameter, before returning and continuing from a new line.
Pages:
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020