diff options
Diffstat (limited to 'game/states')
-rw-r--r-- | game/states/boot.js | 16 | ||||
-rw-r--r-- | game/states/gameover.js | 14 | ||||
-rw-r--r-- | game/states/menu.js | 14 | ||||
-rw-r--r-- | game/states/play.js | 14 | ||||
-rw-r--r-- | game/states/preload.js | 29 |
5 files changed, 87 insertions, 0 deletions
diff --git a/game/states/boot.js b/game/states/boot.js new file mode 100644 index 0000000..91cbb25 --- /dev/null +++ b/game/states/boot.js @@ -0,0 +1,16 @@ +'use strict'; + +function Boot() { +} + +Boot.prototype = { + preload: function() { + this.load.image('preloader', 'assets/preloader.gif'); + }, + create: function() { + this.game.input.maxPointers = 1; + this.game.state.start('preload'); + } +}; + +module.exports = Boot; diff --git a/game/states/gameover.js b/game/states/gameover.js new file mode 100644 index 0000000..7ffb7ed --- /dev/null +++ b/game/states/gameover.js @@ -0,0 +1,14 @@ +'use strict'; + +function GameOver() {} + +GameOver.prototype = { + preload: function () { + }, + create: function () { + }, + update: function () { + } +}; + +module.exports = GameOver; diff --git a/game/states/menu.js b/game/states/menu.js new file mode 100644 index 0000000..c5a609f --- /dev/null +++ b/game/states/menu.js @@ -0,0 +1,14 @@ +'use strict'; + +function Menu() {} + +Menu.prototype = { + preload: function() { + }, + create: function() { + }, + update: function() { + } +}; + +module.exports = Menu; diff --git a/game/states/play.js b/game/states/play.js new file mode 100644 index 0000000..1e9e3e1 --- /dev/null +++ b/game/states/play.js @@ -0,0 +1,14 @@ +'use strict'; + +function Play() {} + +Play.prototype = { + preload: function() { + }, + create: function() { + }, + update: function() { + } +}; + +module.exports = Play; diff --git a/game/states/preload.js b/game/states/preload.js new file mode 100644 index 0000000..877027f --- /dev/null +++ b/game/states/preload.js @@ -0,0 +1,29 @@ +'use strict'; + +function Preload() { + this.asset = null; + this.ready = false; +} + +Preload.prototype = { + preload: function() { + this.asset = this.add.sprite(this.width/2,this.height/2, 'preloader'); + this.asset.anchor.setTo(0.5, 0.5); + + this.load.onLoadComplete.addOnce(this.onLoadComplete, this); + this.load.setPreloadSprite(this.asset); + }, + create: function() { + this.asset.cropEnabled = false; + }, + update: function() { + if(!!this.ready) { + this.game.state.start('menu'); + } + }, + onLoadComplete: function() { + this.ready = true; + } +}; + +module.exports = Preload; |