Game Development Reference
In-Depth Information
orb = new PulsingOrb('#FFF', orbSize);
orb.x = i * ((orbSize * 2) + orbPadding);
orbContainer.addChild(orb);
}
orbContainer.x = orbContainer.y = orbsPosition;
this.addChild(orbContainer);
}
p.addButton = function () {
var btn, event;
btn = new ui.SimpleButton('Play Game');
btn.on('click',this.playGame,this);
btn.regX = btn.width / 2;
btn.x = canvas.width / 2;
btn.y = 400;
btn.setButton({upColor:'#FF0000', color:'#FFF', borderColor:'#FFF',
overColor:'#900'});
this.addChild(btn);
}
p.playGame = function (e) {
this.dispatchEvent(game.GameStateEvents.GAME);
}
p.run = function (tickEvent) {
this.titleTxt.alpha = Math.cos(this.count++ * 0.1) * 0.4 + 0.6;
}
window.game.GameMenu = GameMenu;
}(window));
This menu contains a simple text object, which is the title to the game. Under that are five small PulsingOrb
objects that are created to add some visuals to the screen. Finally, a button, using the SimpleButton
component, is added below. The important thing to notice in this class is the button click handler, which
dispatches the GameStateEvents.GAME event. When this menu is added to the application, a listener will be set
on it for this event, which will take the appropriate action when it is dispatched. The main game menu is shown
in Figure 10-1 .
 
Search WWH ::




Custom Search