Game Development Reference
In-Depth Information
private var explodeSmallTiles:Array;
private var explodeLargeTiles:Array;
They are both set by reading data from the XML:
explodeSmallTiles = tileXML.smallexplode.@tiles.split(",");
explodeLargeTiles = tileXML.largeexplode.@tiles.split(",");
The data looks like this:
<smallexplode tiles="17,18,17"></smallexplode>
<largeexplode tiles="17,18,19,18,17"></largeexplode>
The first explosion uses only the first two explosion tiles. We create a simple animation sequence
by specifying that we play tile 17, then tile 18, and then tile 17 again. Let's look at our tile sheet
again; see Figure 6-10.
Figure 6-10. The tile sheet
If we play tile 17 (the smallest explosion tile), tile 18, and tile 17 again (and then display no tile),
we will have a nice, relatively simple explode animation. This will be used for player and enemy
missiles that hit a TILE_WALL and harmlessly explode.
The larger array of tiles is set up to play in this order: 17, 18,19,18, and 17. This will create a
larger, longer animation that will be used when the player hits an enemy with a missile and when
the player is destroyed.
We chose to set these in the TilesheetDataXML file to keep our game clean of any hard-coded
data references. We could have easily just set all of these arrays up in code, but then the game
would be less easily reused and reskinned.
The initTileSheetData function
The GameDemo constructor is set up to simply call the initTileSheetData function and then print
out the lengths of the arrays that were created in that function. To assign data to these arrays, the
initTilesheetData function simply loops through the XML represented by the tileXML variable.
This variable is set to the static value of the TilesheetDataXML.XMLData variable. The purpose of
this function is to create a one-dimensional array called tileSheetData that will hold the constant
value assigned to each tile in the tile sheet in order.
Search WWH ::




Custom Search