Game Development Reference
In-Depth Information
public static const NEW_LEVEL:String = "new level";
//Constructor calls init() only
public function Game() {}
public function newGame():void {}
public function newLevel():void {}
public function runGame():void {}
}
}
The
Game.as
class is a shell that contains only the necessary functions and constants necessary
for a child of it to work with and communicate with the
GameFrameWork.as
class and its child class,
Main.as
, which will be customized for each game.
The two constants,
GAME_OVER
and
NEW_LEVEL
, are used to communicate state changes to the
GameFrameWork
class. The
GameFrameWork
class has listeners for these two events that we have
seen previously.
We also set up the
newGame
,
newLevel
, and
runGame
functions that the
GameFrameWork
will call
when it reaches the
systemNewGame
,
systemNewLevel
, and
systemGamePlay
functions respectively.
Let's create the stub game now to demonstrate how to create the
Main.as
sub class of
GameFrameWork.as
and the
StubGame.as
sub class of this
Game.as
class.
A stub game class
We are about to embark on the first game of this topic using the set of framework classes that we
have covered in this chapter. This is not an ambitious game but is helpful in getting your feet wet
testing the framework code. This will be a good way for you to make sure the entire framework
set of classes are working before we start on the Super Click game in Chapter 3.
Game objective
Click the mouse ten times. That's it. We made the same game in Chapter 1.
Game state screen flow
We are going to need four instances of the
BasicScreen
class for our game. Three of these
screens with contain an instance the
SimpleBlitButton
to move between game states. These
screens will be called
titleScreen
,
instructionsScreen
, and
gameOverScreen
. We will make use
of one other screen called
levelInScreen
. This screen will not make use of a
SimpleBlitButton
to move to a new game state. All four of these
BasicScreen
instances have already been created
as part of the
GameFrameWork
class. We will create a
Main.as
class unique to our game that will
extend
GameFrameWork.as
and customize these screens for our stub game.