Game Development Reference
In-Depth Information
public var formattedTime:String;
public var movesMade:int;
public function GameHistory(won:Boolean, time:int, moves
Made:int) {
this.won = won;
this.time = time;
this.movesMade = movesMade;
}
}
s not much to this class. This is
just the most basic set of data. You could feasibly store all sorts of
information about how the player performed, but for this example,
we
That
'
s it. As you can see, there
'
re limiting it to whether or not they won (as opposed to quitting
prematurely), how much time it took them, and the number of
moves they made. This information is stored in the MixUp game-
History Array and used by the Results Class.
'
public class Results extends MovieClip {
static public const PLAY_AGAIN:String = " playAgain " ;
static public const MAIN_MENU:String = " mainMenu " ;
public var movesMadeText:TextField;
public var finalTimeText:TextField;
public var playAgainButton:SimpleButton;
public var mainMenuButton:SimpleButton;
public function Results() {
addEventListener(Event.ADDED_TO_STAGE, addedTo
Stage, false, 0, true);
}
private function addedToStage(e:Event):void {
var history:GameHistory = MixUp.gameHistory[0];
movesMadeText.text = String(history.movesMade);
finalTimeText.text = history.formattedTime;
playAgainButton.addEventListener(MouseEvent.
CLICK, playAgain, false, 0, true);
mainMenuButton.addEventListener(MouseEvent.
CLICK, mainMenu, false, 0, true);
}
private function playAgain(e:MouseEvent):void {
dispatchEvent(new Event(PLAY_AGAIN));
}
Search Nedrilad ::




Custom Search