From 48049a71ab041d8b109e2a7a12a8439ed3be812a Mon Sep 17 00:00:00 2001 From: Justin Worthe Date: Sun, 21 Sep 2014 10:17:08 +0200 Subject: Changed detection of preload completion --- game/states/load.js | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) (limited to 'game/states/load.js') 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'); } }; -- cgit v1.2.3