diff options
author | Justin Worthe <justin.worthe@gmail.com> | 2014-09-21 10:17:08 +0200 |
---|---|---|
committer | Justin Worthe <justin.worthe@gmail.com> | 2014-09-21 10:17:08 +0200 |
commit | 48049a71ab041d8b109e2a7a12a8439ed3be812a (patch) | |
tree | d104d48a8c9107065d0d32497a29a1030ebc3de0 | |
parent | c2ea805dfa4a3494ccc8b38eb609d3167e60c2f0 (diff) |
Changed detection of preload completion
-rw-r--r-- | game/states/load.js | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/game/states/load.js b/game/states/load.js index 3ad43ef..b8ffd92 100644 --- a/game/states/load.js +++ b/game/states/load.js @@ -1,17 +1,16 @@ 'use strict'; function Load() { - this.asset = null; - this.ready = false; + this.loadingSprite = null; } Load.prototype = { preload: function() { - this.asset = this.add.sprite(this.width/2,this.height/2, 'preloader'); - this.asset.anchor.setTo(0.5, 0.5); + this.loadingSprite = this.add.sprite(this.game.width/2,this.game.height/2, 'preloader'); + this.loadingSprite.anchor.setTo(0.5, 0.5); + this.load.setPreloadSprite(this.loadingSprite); + - this.load.onLoadComplete.addOnce(this.onLoadComplete, this); - this.load.setPreloadSprite(this.asset); this.load.image('wall', 'assets/images/wall.svg'); this.load.spritesheet('player-a', 'assets/images/player-a-spritesheet.svg', 100, 100); this.load.spritesheet('player-b', 'assets/images/player-b-spritesheet.svg', 100, 100); @@ -37,15 +36,7 @@ Load.prototype = { this.load.image('keys-b', 'assets/images/keyboard-control-b.svg'); }, create: function() { - this.asset.cropEnabled = false; - }, - update: function() { - if(!!this.ready) { - this.game.state.start('play'); - } - }, - onLoadComplete: function() { - this.ready = true; + this.game.state.start('play'); } }; |