O'Reilly logo

HTML5 Game Development HOTSHOT by Makzan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Managing the scenes

In this first task, we will prepare the scenes, which act as a container for all our game objects.

Prepare for lift off

Before creating the scene flow, we prepare the basic scenes definition.

The scene is set up in the same way as the previous project. However, this time we simplified it into two scenes only. Add the following code in the game.js file:

;(function(){ var game = this.spaceRunner || (this.spaceRunner = {}); // Main Game Flow game.flow = { startGame: function() { game.gameOverScene.hide(); game.gameScene.startOver(); }, gameOver: function() { game.gameOverScene.show(); } }; // Entry Point var init = function() { console.log("Welcome to Space Runner Game."); game.isGameOver = true; game.gameScene.setup(); game.gameOverScene.setup(); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required