Game Development Reference
In-Depth Information
gameOverScreen = new
BasicScreen(FrameWorkStates.STATE_SYSTEM_GAME_OVER,400,400,
false,0x0000dd);
gameOverScreen.createOkButton("OK", new Point(170, 250), 40,
20,screenButtonFormat, 0x000000, 0xff0000,2);
gameOverScreen.createDisplayText("Game Over",100,new
Point(140,150),screenTextFormat);
Creating the level in screen
The levelInScreen is different than the other three screens because it doesn't make use of
BasicScreen classes' okButton . It does make use of custom Main.as variable called levelInText.
This variable will hold the default prefix that will be added to the levelInScreen object's text box
on each new level.
levelInScreen = new BasicScreen(FrameWorkStates.
STATE_SYSTEM_LEVEL_IN, 400, 400, true, 0xaaff0000);
levelInText = "Level ";
levelInScreen.createDisplayText(levelInText,100,new Point(150,150),
screenTextFormat);
//Set standard wait time between levels
waitTime= 30;
We also set the waitTime variable to be 30 frames (or the equivalent of 1 second if our frame rate
is set to 30). This will be used by the STATE_SYSTEM_WAIT as the default wait time. The
levelInScreen uses this state for a transition time delay before the game level starts.
Setting the initial state machine's state
The starting state for our Main.as to run is set by calling the GameFrameWork classes'
switchSystemState function and passing in the state constant we would like to start the game in.
For this game, we are going to state at the title screen.
switchSystemState(FrameWorkStates.STATE_SYSTEM_TITLE);
Starting the game timer
By setting the frameRate variable and then calling the GameFrameWork classes' startTimer
function the framework will begin processing.
//create timer and run it one time
frameRate = 30;
startTimer();
The stub Game.as class
The stub Game class is a very simple game that just waits for the player to click the mouse ten
times before the game ends. It is used to demonstrate the basics of Game.as communication with
Main.as using events. You will need to create a StubGame.as class and save it in the project folder
for your chosen development environment.
Search WWH ::




Custom Search