Game Development Reference
In-Depth Information
Figure 10-3. The game over screen lets players play again or go to the main menu
With all scenes created and ready to use, the main application class will next be created.
Building the Main Application with State Machine
The main application code for the Orb Destroyer game will be encapsulated into a class, but does not need to extend
anything from EaselJS. It will handle the stage setup and the state machine itself. All scene instantiations will be added
directly to the main stage, which will be one of the few properties that will actually be left in global space. A reference
to the canvas will also remain global for easy access across the game scenes. Listing 10-16 shows the initial setup of
the main application.
Listing 10-16. OrbDestroyer.js - The Main Application Class That Runs the State Machine
(function (window) {
window.game = window.game || {}
function OrbDestroyer() {
this.initialize();
}
var p = OrbDestroyer.prototype;
 
Search WWH ::




Custom Search