Game Development Reference
In-Depth Information
p.addMessage = function () {
this.titleTxt = new createjs.Text("YOU DESTROYED THE ORBS!", '40px
Arial','#FFF');
this.titleTxt.x = canvas.width / 2;
this.titleTxt.y = 200;
this.titleTxt.textAlign = 'center';
this.addChild(this.titleTxt);
}
p.addButton = function () {
var btn;
btn = new ui.SimpleButton('Main Menu');
btn.regX = btn.width / 2;
btn.x = canvas.width / 2;
btn.y = 280;
btn.on('click',this.mainMenu, this);
this.addChild(btn);
btn = new ui.SimpleButton('Play Again');
btn.regX = btn.width / 2;
btn.x = canvas.width / 2;
btn.y = 350;
btn.on('click',this.playGame, this);
this.addChild(btn);
}
p.mainMenu = function (e) {
this.dispatchEvent(game.GameStateEvents.MAIN_MENU);
}
p.playGame = function (e) {
this.dispatchEvent(game.GameStateEvents.GAME);
}
window.game.GameOver = GameOver;
}(window));
The GameOver screen is similar to the main menu, except it has two buttons instead of one and does not utilize
a run method. Each button will dispatch the events GameStateEvents.MAIN_MENU and GameStateEvents.GAME ,
respectively. Figure 10-3 demonstrates the game over screen.
 
Search WWH ::




Custom Search