HTML and CSS Reference
In-Depth Information
// Prototype inheritance.
RectShape.prototype = Object.create(createjs.Container.
return RectShape;
3. Then, we create a deiniion of the box based on RectShape . Next, we define a
new Box class:
var game = || ({});
game.Box = (function(){
function Box(){, game.setting.boxWidth, game.
setting.boxHeight); // super with argument
Box.prototype = Object.create(game.RectShape.prototype);
return Box;
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
var game = || ({});
game.NumberBox = (function(){
function NumberBox(value){; // 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