Game Development Reference
In-Depth Information
public var enemyHealthPoints:Number;
public var enemyShotDelay:int;
public function Level() {
}
}
}
We now need to modify the Level1.as file to add in two new elements. Add the following code to
the Level1.as file variable assignment section:
enemyShotDelay = 10;
enemyHealthPoints = 2;
Finishing up the NoTanks.as file
We are now going to quickly go through all of the code necessary to make the
GameDemoInteration6.as file into a complete game. There are quite a few little things we need to
do, but we have the most complicated code out of the way. When we are done, you will have a
complete game that is ready for more levels and any enhancements you can think of.
Once again, we are going to change to a new class name for this iteration.
Here is the new class name and location for the Flash IDE:
/source/projects/notanks/flashIDE/com/efg/games/notanks/NoTanks.as
Here is the new class name and location for the Flex SDK:
/source/projects/notanks/flexSDK/src/com/efg/games/notanks]NoTanks.as
Changing the class name for NoTanks.as
We have a new file name for the game, so we will once again need to change the class name to
match. We will also need to change the name of the constructor function.
It is very important that you change the NoTanks class to extend Game rather than Sprite . Here is
the new class definition. First, we will change to the new class name
public class NoTanks extends Game
{
and then the constructor name:
public function NoTanks() {
Adding to the class import section for NoTanks.as
The very top of your new NoTanks.as file should look exactly like the following; you don't need to
type in the comments, but they are for reference if you need them:
package com.efg.games.notanks
{
import flash.display.BitmapData;
Search WWH ::




Custom Search