Game Development Reference
In-Depth Information
p.gameStateLevelSelect = function () {
var scene = new game.LevelSelect()
scene.on(game.GameStateEvents.GAME, this.onStateEvent, this, true,
{state:game.GameStates.GAME});
scene.on(game.GameStateEvents.MAIN_MENU, this.onStateEvent, this,
true, {state:game.GameStates.MAIN_MENU});
stage.addChild(scene);
this.disposeCurrentScene();
this.currentScene = scene;
this.changeState(game.GameStates.RUN_SCENE);
}
p.gameStateGame = function (tickEvent) {
var gameData = data.GameData.levelData[data.GameData.currentLevel -
1];
var scene = new game.Game(gameData, tickEvent.time);
scene.on(game.GameStateEvents.LEVEL_COMPLETE, this.onStateEvent,
this, true, {state:game.GameStates.LEVEL_COMPLETE});
scene.on(game.GameStateEvents.MAIN_MENU, this.onStateEvent, this,
true, {state:game.GameStates.MAIN_MENU});
stage.addChild(scene);
this.disposeCurrentScene()
this.currentScene = scene;
this.changeState(game.GameStates.RUN_SCENE);
}
p.gameStateLevelComplete = function () {
var scene = new game.LevelComplete();
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);
}
p.gameStateRunScene = function (tickEvent) {
if (this.currentScene.run) {
this.currentScene.run(tickEvent);
}
}
p.onTick = function (e) {
if (this.currentGameStateFunction != null) {
this.currentGameStateFunction(e);
}
stage.update();
}
window.game.Villager = Villager;
}(window));
Search WWH ::




Custom Search