Skip to content

Commit 9f49304

Browse files
committed
The StateManager would incorrectly call loadUpdate while the game was paused or if the State didn't have an update method defined even after the loader was completed.
The StateManager would incorrectly call `loadRender` while the game was paused or if the State didn't have an `render` method defined even after the loader was completed.
1 parent 7b011fe commit 9f49304

2 files changed

Lines changed: 25 additions & 14 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,8 @@ Version 2.3.1 - "Katar" - in dev
284284
* TilemapLayer was missing the Input component (thanks @uhe1231 #1700)
285285
* PIXI.Graphics in Canvas mode wouldn't respect the objects visible or alpha zero properties, rendering it regardless (thanks @TimvdEijnden #1720)
286286
* Enabling Arcade Physics would add the deltaCap property onto Phaser.Time, even though the property doesn't exist any more, changing the class shape in the process.
287+
* The StateManager would incorrectly call `loadUpdate` while the game was paused or if the State didn't have an `update` method defined even after the loader was completed.
288+
* The StateManager would incorrectly call `loadRender` while the game was paused or if the State didn't have an `render` method defined even after the loader was completed.
287289

288290
For changes in previous releases please see the extensive [Version History](https://github.com/photonstorm/phaser/blob/master/CHANGELOG.md).
289291

src/core/StateManager.js

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -614,9 +614,12 @@ Phaser.StateManager.prototype = {
614614
*/
615615
update: function () {
616616

617-
if (this._created && this.onUpdateCallback)
617+
if (this._created)
618618
{
619-
this.onUpdateCallback.call(this.callbackContext, this.game);
619+
if (this.onUpdateCallback)
620+
{
621+
this.onUpdateCallback.call(this.callbackContext, this.game);
622+
}
620623
}
621624
else
622625
{
@@ -634,9 +637,12 @@ Phaser.StateManager.prototype = {
634637
*/
635638
pauseUpdate: function () {
636639

637-
if (this._created && this.onPauseUpdateCallback)
640+
if (this._created)
638641
{
639-
this.onPauseUpdateCallback.call(this.callbackContext, this.game);
642+
if (this.onPauseUpdateCallback)
643+
{
644+
this.onPauseUpdateCallback.call(this.callbackContext, this.game);
645+
}
640646
}
641647
else
642648
{
@@ -681,18 +687,21 @@ Phaser.StateManager.prototype = {
681687
*/
682688
render: function () {
683689

684-
if (this._created && this.onRenderCallback)
690+
if (this._created)
685691
{
686-
if (this.game.renderType === Phaser.CANVAS)
687-
{
688-
this.game.context.save();
689-
this.game.context.setTransform(1, 0, 0, 1, 0, 0);
690-
this.onRenderCallback.call(this.callbackContext, this.game);
691-
this.game.context.restore();
692-
}
693-
else
692+
if (this.onRenderCallback)
694693
{
695-
this.onRenderCallback.call(this.callbackContext, this.game);
694+
if (this.game.renderType === Phaser.CANVAS)
695+
{
696+
this.game.context.save();
697+
this.game.context.setTransform(1, 0, 0, 1, 0, 0);
698+
this.onRenderCallback.call(this.callbackContext, this.game);
699+
this.game.context.restore();
700+
}
701+
else
702+
{
703+
this.onRenderCallback.call(this.callbackContext, this.game);
704+
}
696705
}
697706
}
698707
else

0 commit comments

Comments
 (0)