Skip to content

Commit fc6b7dd

Browse files
committed
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.
1 parent 19b45b1 commit fc6b7dd

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ Version 2.1.2 - "Whitebridge" - in development
7575

7676
### New Features
7777

78+
* 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.
7879

7980

8081
### Updates

src/core/StateManager.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,39 @@ Phaser.StateManager.prototype = {
451451

452452
},
453453

454+
/**
455+
* Nulls all State level Phaser properties, including a reference to Game.
456+
*
457+
* @method Phaser.StateManager#unlink
458+
* @param {string} key - State key.
459+
* @protected
460+
*/
461+
unlink: function (key) {
462+
463+
if (this.states[key])
464+
{
465+
this.states[key].game = null;
466+
this.states[key].add = null;
467+
this.states[key].make = null;
468+
this.states[key].camera = null;
469+
this.states[key].cache = null;
470+
this.states[key].input = null;
471+
this.states[key].load = null;
472+
this.states[key].math = null;
473+
this.states[key].sound = null;
474+
this.states[key].scale = null;
475+
this.states[key].state = null;
476+
this.states[key].stage = null;
477+
this.states[key].time = null;
478+
this.states[key].tweens = null;
479+
this.states[key].world = null;
480+
this.states[key].particles = null;
481+
this.states[key].rnd = null;
482+
this.states[key].physics = null;
483+
}
484+
485+
},
486+
454487
/**
455488
* Sets the current State. Should not be called directly (use StateManager.start)
456489
*

0 commit comments

Comments
 (0)