HTML and CSS Reference
In-Depth Information
}
// Prototype inheritance.
RectShape.prototype = Object.create(createjs.Container.
prototype);
return RectShape;
})();
}).call(this);
3. Then, we create a deiniion of the box based on RectShape . Next, we define a
new Box class:
;(function(){
var game = this.game || (this.game={});
game.Box = (function(){
function Box(){
game.RectShape.call(this, game.setting.boxWidth, game.
setting.boxHeight); // super with argument
}
Box.prototype = Object.create(game.RectShape.prototype);
return Box;
})();
}).call(this);
4. The NumberBox object is of the shape of a rectangle with a number on top of it.
So, it is a container that contains the box and the numbered text. The box is created
when it extends the Box logic. So we only add Text to this logic block:
// Number Box
;(function(){
var game = this.game || (this.game={});
game.NumberBox = (function(){
function NumberBox(value){
game.Box.call(this); // super, it draws rect shape.
this.value = value;
// Text on top of the rect shape.
var text = new createjs.Text(value, '24px Impact', 'white');
text.textBaseline = 'middle';
text.textAlign = 'center';
text.x = game.setting.boxWidth/2;
text.y = game.setting.boxHeight/2;
 
Search WWH ::




Custom Search