Game Development Reference
In-Depth Information
idleBtn.x = runBtn.x + runBtn.width + 10;
stage.addChild(jumpBtn, runBtn, idleBtn);
}
The Runner sprite is positioned and added to the stage; same goes for the three buttons. Figure 8-8 demonstrates
all custom display objects added to the stage.
Figure 8-8. Custom sprite called Runner on stage with three simple buttons
The Complete Code for Running Man
The entire runningMan.js code for the Running Man application is shown in Listing 8-24.
Listing 8-24. Complete Running Man Application Code
var stage, queue, preloader, spritesheet, runner;
function preload() {
queue = new createjs.LoadQueue();
queue.loadManifest([
{id:"runner", src:"img/runningMan.png"}
],false);
init();
}
function init(){
stage = new createjs.Stage(document.getElementById('canvas'));
createjs.Ticker.on('tick', stage);
stage.enableMouseOver();
preloader = new ui.Preloader('#FFF','#000');
 
Search WWH ::




Custom Search