Game Development Reference
In-Depth Information
public var clipPaddle1:Sprite, clipPaddle2:Sprite,
clipPuck:Sprite;
public var clipGoal1:Sprite, clipGoal2:Sprite;
public var clipWall1:Sprite, clipWall2:Sprite, clipWall3:
Sprite, clipWall4:Sprite, clipWall5:Sprite, clipWall6:
Sprite;
public var clipTouchController1:GameTouchController,
clipTouchController2:GameTouchController;
public var clipScoreDisplay1:MovieClip, clipScoreDisplay2:
MovieClip;
private var mStateMachine:FSMManager;
private var mEngine:AirHockeyEngine;
private var mPlayer1Score:int = 0, mPlayer2Score:int = 0;
private var mOverlayClip:MovieClip;
The first four constants defined here represent the four different
states in which the game can function. Our state machine requires
aunique
identifier for every state registered with it, so this is
an easy way to enumerate them. The PRE_GAME state will consist
of the countdown prior to gameplay. GAME_ACTIVE will represent
thegameinastateofplay,wherebothplayerscangiveinputand
thephysicswillbeactive.TheGAME_SCOREstatewilltakeover
when a player scores, displaying who scored and resetting the
game board. Finally, when the game is finished, it will go to the
POST_GAME state.
The second set of constant values contains the names of over-
lays that will be displayed in the game at different points. These
name values correspond to MovieClips in the XFL library, as
shown in Fig. 16.3 .
All of the public variables map to various display objects, all
pre-fixed with the word
int
This will allow us to easily pass
these objects into the engine, so it can bind them to the physics
simulation. Finally, there are member variables storing an instance
of the finite-state manager (more on that in a moment), an
instance of the AirHockeyEngine , the scores of the two players, and
a reference that will be used to store which overlay clip is currently
active. When none is displayed, this property should be null.
clip.
Figure 16.3 The overlay
MovieClips used in the
game their class names
match the constant values
in the Game class.
Search Nedrilad ::




Custom Search