HTML and CSS Reference
In-Depth Information
Inside the game.js ile, we prepare the following game seings object at the start of the ile:
var game = this.game || (this.game={});
var createjs = createjs || {};
// Settings
;(function(game){
game.canvas = document.getElementById('canvas');
game.setting = {
gameWidth: game.canvas.width,
gameHeight: game.canvas.height,
};
}).call(this, game);
In this game, we set up three layers. All the game elements will be put in any one of the
layers. The following figure shows the planning of layers. These layers are the background
layer, city layer, and user interface layer. For example, city graphics and buildings are placed
in the city layer. Butons and interface indicators are placed in the UI layer. The background
and clouds will be placed in the background layer.
Engage thrusters
In the following steps, we will code the planned layer structure:
1. The layer's block of code defines the three layers. We wrap all the layers' code into
a self-invoked funcion:
;(function(game, cjs){
// all following layers' code goes here.
}.call(this, game, createjs);
 
Search WWH ::




Custom Search