Skip to content

Commit 0054dc9

Browse files
committed
The Loader now directly calls StateManager.loadComplete rather than the StateManager listening for the loadComplete event, because Loader.reset unbinds this event (and it's easy to accidentally remove it too)
Loader.onLoadComplete is dispatched *before* the Loader is reset. If you have a `create` method in your State please note that the Loader will have been reset before this method is called. This allows you to immediately re-use the Loader without having to first reset it manually.
1 parent dfc8ff3 commit 0054dc9

3 files changed

Lines changed: 5 additions & 2 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ Thanks to @pnstickne for vast majority of this update.
118118
* Loader.reset has a new optional 2nd parameter `clearEvents` which if set to `true` (the default is false) will reset all event listeners bound to the Loader.
119119
* If `Body.customSeparateX` or `customSeparateY` is `true` then the Body will no longer be automatically separated from a **Tilemap** collision or exchange any velocity. The amount of pixels that the Body has intersected the tile is available in `Body.overlapX` and `overlapY`, so you can use these values to perform your own separation in your collision callback (#992)
120120
* TilemapParser will now set the `.type` property for ObjectLayer Objects (thanks @mikaturunen #1609)
121+
* The Loader now directly calls StateManager.loadComplete rather than the StateManager listening for the loadComplete event, because Loader.reset unbinds this event (and it's easy to accidentally remove it too)
122+
* Loader.onLoadComplete is dispatched *before* the Loader is reset. If you have a `create` method in your State please note that the Loader will have been reset before this method is called. This allows you to immediately re-use the Loader without having to first reset it manually.
121123

122124
### Bug Fixes
123125

src/core/StateManager.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ Phaser.StateManager.prototype = {
146146

147147
this.game.onPause.add(this.pause, this);
148148
this.game.onResume.add(this.resume, this);
149-
this.game.load.onLoadComplete.add(this.loadComplete, this);
150149

151150
if (this._pendingState !== null)
152151
{
@@ -580,7 +579,7 @@ Phaser.StateManager.prototype = {
580579
*/
581580
loadComplete: function () {
582581

583-
// console.log('loadComplete');
582+
// console.log('SM loadComplete');
584583

585584
if (this._created === false && this.onCreateCallback)
586585
{

src/loader/Loader.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,6 +1341,8 @@ Phaser.Loader.prototype = {
13411341

13421342
this.reset();
13431343

1344+
this.game.state.loadComplete();
1345+
13441346
},
13451347

13461348
/**

0 commit comments

Comments
 (0)