/
Main.js
30 lines (25 loc) · 819 Bytes
/
Main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"use strict";
CLAZZ("Main", {
DOM:null,
game:null,
pool:null,
CONSTRUCTOR:function(){
this.pool = new DOC.Pool();
this.DOM = DOC.index(document.body, null, this);
this.pool.add(this);
this.setGameState("boot");
},
setGameState:function( strstate ){
var state = DOC.resolve( "resources.states." + strstate );
if( !state ){
console.log("Game state not defined: resources.states." + strstate )
return;
}
var inst = CLAZZ.get( state.clazz || "GameState", {
resources:state,
pool:this.pool
});
if( this.game ) this.game.state.add( strstate, inst, true );
else this.game = new Phaser.Game( 1920, 1080, Phaser.AUTO, this.DOM.container, inst );
}
});