Game Development Reference
In-Depth Information
p.gameReady = function () {
createjs.Ticker.setFPS(60);
createjs.Ticker.on("tick", this.onTick, this);
this.changeState(game.GameStates.MAIN_MENU);
}
p.changeState = function (state) {
switch (state) {
case game.GameStates.MAIN_MENU:
this.currentGameStateFunction = this.gameStateMainMenu;
break;
case game.GameStates.LEVEL_SELECT:
this.currentGameStateFunction = this.gameStateLevelSelect;
break;
case game.GameStates.GAME:
this.currentGameStateFunction = this.gameStateGame;
break;
case game.GameStates.LEVEL_COMPLETE:
this.currentGameStateFunction = this.gameStateLevelComplete;
break;
case game.GameStates.RUN_SCENE:
this.currentGameStateFunction = this.gameStateRunScene;
break;
}
}
p.onStateEvent = function (e, obj) {
this.changeState(obj.state);
}
p.disposeCurrentScene = function () {
if (this.currentScene != null) {
stage.removeChild(this.currentScene);
if (this.currentScene.dispose) {
this.currentScene.dispose();
}
this.currentScene = null;
}
}
p.gameStateMainMenu = function () {
var scene = new game.GameMenu();
scene.on(game.GameStateEvents.GAME, this.onStateEvent, this, true,
{state:game.GameStates.GAME});
scene.on(game.GameStateEvents.LEVEL_SELECT, this.onStateEvent, this,
true, {state:game.GameStates.LEVEL_SELECT});
stage.addChild(scene);
this.disposeCurrentScene();
this.currentScene = scene;
this.changeState(game.GameStates.RUN_SCENE);
}
Search WWH ::




Custom Search