Game Development Reference
In-Depth Information
p.addScore = function () {
var scorePoint = {x:220, y:310};
var scoreTxt = new createjs.BitmapText(game.score, spritesheet);
scoreTxt.x = scorePoint.x;
scoreTxt.y = scorePoint.y;
this.addChild(scoreTxt);
}
p.addButton = function () {
var playBtn, menuBtn;
var playBtnPoint = {x:140, y:380};
var menuBtnPoint = {x:310, y:380};
var me = this;
playBtn = new ui.SimpleButton('Play Again');
playBtn.on('click', this.playAgain, this);
playBtn.setButton({upColor:'#d2354c', color:'#FFF',
borderColor:'#FFF', overColor:'#900'});
playBtn.x = playBtnPoint.x;
playBtn.y = playBtnPoint.y;
this.addChild(playBtn);
menuBtn = new ui.SimpleButton('Main Menu');
menuBtn.on('click', this.mainMenu, this);
menuBtn.setButton({upColor:'#d2354c', color:'#FFF',
borderColor:'#FFF', overColor:'#900'});
menuBtn.x = menuBtnPoint.x;
menuBtn.y = menuBtnPoint.y;
this.addChild(menuBtn);
}
p.playAgain = function (e) {
this.dispatchEvent(game.GameStateEvents.GAME);
}
p.mainMenu = function (e) {
this.dispatchEvent(game.GameStateEvents.MAIN_MENU);
}
window.game.GameOver = GameOver;
}(window));
In this scene, a series of methods add, position, and animate the elements on the screen. The game over screen is
shown in Figure 11-11 .
Search WWH ::




Custom Search