Game Development Reference
In-Depth Information
will also contain all of the state functions that coincide with the state variables in the
FrameWorkStates class. All of the functions in the GameFrameWork.as are public so all can be
overridden by the Main.as if needed. In this way, we can customize the behavior of the state
functions if we need to.
For example, in later chapters, we will want to play music on the title screen. The function call to
play the music will need to be added to the systemTitle state function. Not all games will need
this though, so we will not add it to the GameFrameWork.as file's systemTitleFunction . Instead, we
will create a new version of the function in Main.as to override the one in GameFrameWork.as . The
new one will play the sound needed and then call the systemTitle function inside
GameFrameWork.as with the super.systemTitle() function call.
package com.efg.framework
{
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.MovieClip;
import flash.events.Event;
import flash.geom.Point;
import flash.text.TextFormat;
import flash.utils.Timer;
import flash.events.TimerEvent;
public class GameFrameWork extends MovieClip {
public static const EVENT_WAIT_COMPLETE:String = "wait complete";
public var systemFunction:Function;
public var currentSystemState:int;
public var nextSystemState:int;
public var lastSystemState:int;
public var appBackBitmapData:BitmapData;
public var appBackBitmap:Bitmap; ;
public var frameRate:int;
public var timerPeriod:Number;
public var gameTimer:Timer;
public var titleScreen:BasicScreen;
public var gameOverScreen:BasicScreen;
public var instructionsScreen:BasicScreen;
public var levelInScreen:BasicScreen;
public var screenTextFormat:TextFormat;
public var screenButtonFormat:TextFormat;
public var levelInText:String;
public var scoreBoard:ScoreBoard;
public var scoreBoardTextFormat:TextFormat;
//Game is our custom class to hold all logic for the game.
public var game:Game;
//waitTime is used in conjunction with the
//STATE_SYSTEM_WAIT state
Search WWH ::




Custom Search