StateManager.unlink will null all State-level Phaser properties, such as game, add, etc. Useful if you never need to return to the State again.

This commit is contained in:
photonstorm 2014-09-11 21:04:31 +01:00
parent 19b45b1c59
commit fc6b7dd36c
2 changed files with 34 additions and 0 deletions

View file

@ -75,6 +75,7 @@ Version 2.1.2 - "Whitebridge" - in development
### New Features
* StateManager.unlink will null all State-level Phaser properties, such as `game`, `add`, etc. Useful if you never need to return to the State again.
### Updates

View file

@ -451,6 +451,39 @@ Phaser.StateManager.prototype = {
},
/**
* Nulls all State level Phaser properties, including a reference to Game.
*
* @method Phaser.StateManager#unlink
* @param {string} key - State key.
* @protected
*/
unlink: function (key) {
if (this.states[key])
{
this.states[key].game = null;
this.states[key].add = null;
this.states[key].make = null;
this.states[key].camera = null;
this.states[key].cache = null;
this.states[key].input = null;
this.states[key].load = null;
this.states[key].math = null;
this.states[key].sound = null;
this.states[key].scale = null;
this.states[key].state = null;
this.states[key].stage = null;
this.states[key].time = null;
this.states[key].tweens = null;
this.states[key].world = null;
this.states[key].particles = null;
this.states[key].rnd = null;
this.states[key].physics = null;
}
},
/**
* Sets the current State. Should not be called directly (use StateManager.start)
*