Game Development Reference
In-Depth Information
PulsingOrb.prototype.initialize = function (color, size) {
size = size != undefined ? size : 20;
color = color != undefined ? color : '#F00';
this.size = size;
this.Shape_initialize();
this.alpha = Math.random();
this.graphics.beginFill(color).drawCircle(0, 0, size);
this.on('tick', this.pulse);
}
PulsingOrb.prototype.pulse = function () {
this.alpha = Math.cos(this.count++ * 0.1) * 0.4 + 0.6;
}
window.PulsingOrb = PulsingOrb;
}());
Building the Game Over Screen
One more scene is needed before getting into the main application code. When the game is over, a game over screen
should appear, with an option to replay the game or go back to the main menu screen. The GameOver container class is
shown in Listing 10-15.
Listing 10-15. GameOver.js - The Game Over Scene
(function (window) {
window.game = window.game || {}
function GameOver() {
this.initialize();
}
var p = GameOver.prototype = new createjs.Container();
p.Container_initialize = p.initialize;
p.initialize = function () {
this.Container_initialize();
this.addBG();
this.addMessage();
this.addButton();
}
p.addBG = function () {
var bg = new createjs.Shape();
bg.graphics.beginFill('#09E').drawRect(0, 0, canvas.width,
canvas.height);
this.addChild(bg);
}
 
Search WWH ::




Custom Search