HTML and CSS Reference
In-Depth Information
// hearts for the lives
this.hearts = [];
this.heartsContainer = new createjs.Container();
this.heartsContainer.x = 5;
this.heartsContainer.y = 5;
game.stage.addChild(this.heartsContainer);
this.resetHearts();
// existing init code goes here.
},
};
2. When we restart the game later, we will need to recreate the hearts. We use the
following code to empty the hearts' container and recreate hearts inside it:
game.gameView = {
resetHearts: function() {
this.heartsContainer.removeAllChildren();
this.hearts.length = 0;
for (vari = 0; i<game.setting.initialLifes; i++) {
var heart = new game.RectShape(18, 18, {fillColor:'red'})
heart.x = i * 20;
this.heartsContainer.addChild(heart);
this.hearts.push(heart);
}
},
// existing gameView code here
};
3. We add a funcion to the game view to remove a heart whenever this funcion
is called:
game.gameView = {
deduceLife: function(){
var heart = game.gameView.hearts[game.lifes];
this.heartsContainer.removeChild(heart);
},
// existing gameView code here
};
 
Search WWH ::




Custom Search