From fb733ddcca3df27a8910efd5d0add55e0558ffc2 Mon Sep 17 00:00:00 2001 From: photonstorm Date: Wed, 26 Nov 2014 12:56:19 +0000 Subject: [PATCH] onPreRenderCallback wasn't being cleared on a State swap. --- README.md | 1 + src/core/StateManager.js | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 2e1b03e86..d78fdb7c7 100644 --- a/README.md +++ b/README.md @@ -251,6 +251,7 @@ This fixes a bug in FF where it would use the default DOMMouseWheel (thanks @pns * When you change State the P2 Physics world is no longer fully cleared. All of the bodies, springs, fixtures, materials and constraints are removed - but config settings such as gravity, restitution, the contact solver, etc are all retained. The P2.World object is only created the very first time you call Physics.startSystem. Every subsequent call hits P2.World.reset instead. This fixes "P2.World gravity broken after switching states" (and other related issues) (#1292 #1289 #1176) * Text.lineSpacing works correctly again. Before no space was added between the lines (thanks @intimidate #1367 and @brejep #1366) * P2.BodyDebug always lagged behind the position of the Body it was tracking by one frame, which became visible at high speeds. It now syncs its position in the Body.postUpdate which prevents this from happening (thanks @valueerror) +* A State.preRender callback wan't removed correctly when switching States. ### Pixi 2.1.0 New Features diff --git a/src/core/StateManager.js b/src/core/StateManager.js index b0388430a..eabf757c0 100644 --- a/src/core/StateManager.js +++ b/src/core/StateManager.js @@ -97,7 +97,7 @@ Phaser.StateManager = function (game, pendingState) { this.onResizeCallback = null; /** - * @property {function} onPreRenderCallback - This is called before the state is rendered and before the stage is cleared. + * @property {function} onPreRenderCallback - This is called before the state is rendered and before the stage is cleared but after all game objects have had their final properties adjusted. */ this.onPreRenderCallback = null; @@ -225,6 +225,7 @@ Phaser.StateManager.prototype = { this.onLoadUpdateCallback = null; this.onCreateCallback = null; this.onUpdateCallback = null; + this.onPreRenderCallback = null; this.onRenderCallback = null; this.onResizeCallback = null; this.onPausedCallback = null; @@ -427,10 +428,10 @@ Phaser.StateManager.prototype = { { var valid = false; - if (this.states[key]['preload']) { valid = true; } - if (this.states[key]['create']) { valid = true; } - if (this.states[key]['update']) { valid = true; } - if (this.states[key]['render']) { valid = true; } + if (this.states[key]['preload'] || this.states[key]['create'] || this.states[key]['update'] || this.states[key]['render']) + { + valid = true; + } if (valid === false) {