Game Development Reference
In-Depth Information
//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
// it suspends the game and allows animation or other processing to finish
public var waitTime:int;
public var waitCount:int = 0;
//added chapter 11
public var frameRateProfiler:FrameRateProfiler;
public function GameFrameWork() {
soundManager = new SoundManager(); // moved;
}
//function added in chapter 11
public function addedToStage(e:Event = null):void {
stage.addEventListener(KeyboardEvent.KEY_DOWN,keyDownListener);
this.focusRect=false; // added chapter 11
stage.focus = stage; // added chapter 11
trace("gamFrameWork added to stage");
}
public function init():void {
trace("inner init stub");
}
public function frameRateProfileComplete(e:Event):void {
// stub
}
public function setApplicationBackGround(width:Number, height:Number,
isTransparent:Boolean = false, color:uint = 0x000000):void {
appBackBitmapData = new BitmapData(width, height, isTransparent, color);
appBackBitmap = new Bitmap(appBackBitmapData);
addChild(appBackBitmap);
}
//changed for chapter 11
public function startTimer(timeBasedAnimation:Boolean=false):void {
stage.frameRate = frameRate;
if (timeBasedAnimation) {
lastTime = getTimer();
addEventListener(Event.ENTER_FRAME, runGameEnterFrame);
}else{
timerPeriod = 1000 / frameRate;
gameTimer=new Timer(timerPeriod);
gameTimer.addEventListener(TimerEvent.TIMER, runGame);
gameTimer.start();
}
}
Search WWH ::




Custom Search