diff options
Diffstat (limited to 'game/states/preload.js')
-rw-r--r-- | game/states/preload.js | 29 |
1 files changed, 29 insertions, 0 deletions
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; |