HTML and CSS Reference
In-Depth Information
var ticksCount = createjs.Ticker.getTicks(/*exclude_pause=*/
if (ticksCount % game.setting.ticksPerNewBox === 0) {
// logic for every 80 ticks
3. In the game view, we make each box fall at a short distance:
game.gameView = {
moveObjects: function() {
for (var i=0, len=this.numberBoxes.length; i<len; i++) {
var box = this.numberBoxes[i];
box.y += game.setting.fallingSpeed;
// existing gameView code here
Now, the boxes should keep showing up at the top and falling down to the botom when the
game loads.
Objective complete - mini debriefing
The icker is a centralized clock for the enire game. The clock moves and icks in every unit.
In every ick, we refresh the canvas rendering by calling stage.update() .
Besides rendering, we will move down all the exising boxes to make them fall. Ater a while,
we will make a numbered box fall from the top of the screen.
Inside the ick event handler, we can check whether Ticker is under the pause state by
e.paused . It is useful to globally pause a game and sill be limited to the logic that runs
in every game's loop regardless of the pause state.
The benefit of having a global Ticker is that we can control the start and pause of all
the game elements at only one place. We can use Ticker.setPaused(true) to pause
the game.
Search WWH ::

Custom Search