Game Development Reference
In-Depth Information
break;
case "goal":
numberToPush = SPRITE_GOAL;
break;
case "heart":
numberToPush = SPRITE_HEART;
break;
case "skull":
numberToPush = SPRITE_SKULL;
break;
case "clock":
numberToPush = SPRITE_CLOCK;
break;
}
}
tileSheetData.push(numberToPush);
}
}
Here is a detailed description of the main points of this function:
This function is very similar to the same named function in the No Tanks! game. Its job is to read
in the TileSheetDataXML class and place a constant representing the tile type into each cell of a
single-dimensional array ( tileSheetData ) representing our tile sheet tiles.
1.
First, it initializes the playerFrameList and the tileSheetData arrays. The
playerFrameList array will eventually contain the id s 0 , 1 , and 2 . Those are the first
three frames in our tile sheet for animating the car and its wheels.
2.
Next, it loops through all of the tile nodes in the XML as if they are in an array. This is
a powerful feature of the ActionScript 3.0 XML class.
3.
During this loop, we first check to see if the tile is one of the two basic types:
TILE_MOVE or TILE_WALL . If it isn't one of those two, but is a sprite type, we drop into the
switch/case and set the tile type based on the name attribute.
4.
Finally, the local numberToPush (representing the constant value for this tile) is pushed
into the tileSheetData array.
The newLevel function
Now, let's look at the complete code for the newLevel function:
override public function newLevel():void {
stage.focus = this;
if (level ==levels.length-1) level = 0;
level++;
heartsTotal = 0;
Search WWH ::




Custom Search