Game Development Reference
In-Depth Information
if (btn == this.gameBtn) {
localStorage.clear();
data.PlayerData.setLocalStorage();
}
this.dispatchEvent(game.GameStateEvents.LEVEL_SELECT);
}
window.game.GameMenu = GameMenu;
}());
This menu is not unlike other menus built in this topic so far. A title sprite and button sprites are created
and positioned accordingly. Both buttons call the same handler function, which will use the target of the event to
determine what to do. In the case that the button clicked was gameBtn , the local storage is cleared and new template
data is set. In both cases, the LEVEL_SELECT state event is dispatched, which will bring up the level select scene.
Figure 14-9 shows the main menu screen.
Figure 14-9. The game's main menu screen
Search WWH ::




Custom Search