Skip to content

Commit be4d42a

Browse files
committed
The StateManager now looks for a function called 'resumed' which is called when a game un-pauses (fixes phaserjs#358)
1 parent ea4873e commit be4d42a

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ New features:
124124
* Tilemap.createCollisionObjects will parse Tiled data for objectgroups and convert polyline instances into physics objects you can collide with in the world.
125125
* Loader can now load JSON files specifically (game.load.json) and they are parsed and stored in the Game.Cache. Retrieve with game.cache.getJSON(key).
126126
* TileSprites can now receive full Input events, dragging, etc and be positioned in-world and fixed to cameras.
127+
* The StateManager now looks for a function called 'resumed' which is called when a game un-pauses.
127128

128129

129130
Updates:

src/core/StateManager.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ Phaser.StateManager = function (game, pendingState) {
9393
*/
9494
this.onPausedCallback = null;
9595

96+
/**
97+
* @property {function} onResumedCallback - This will be called when the state is resumed from a paused state.
98+
*/
99+
this.onResumedCallback = null;
100+
96101
/**
97102
* @property {function} onShutDownCallback - This will be called when the state is shut down (i.e. swapped to another state).
98103
*/
@@ -195,6 +200,7 @@ Phaser.StateManager.prototype = {
195200
this.onUpdateCallback = null;
196201
this.onRenderCallback = null;
197202
this.onPausedCallback = null;
203+
this.onResumedCallback = null;
198204
this.onDestroyCallback = null;
199205
}
200206

@@ -370,6 +376,7 @@ Phaser.StateManager.prototype = {
370376
this.onPreRenderCallback = this.states[key]['preRender'] || null;
371377
this.onRenderCallback = this.states[key]['render'] || null;
372378
this.onPausedCallback = this.states[key]['paused'] || null;
379+
this.onResumedCallback = this.states[key]['resumed'] || null;
373380

374381
// Used when the state is no longer the current active state
375382
this.onShutDownCallback = this.states[key]['shutdown'] || this.dummy;
@@ -418,7 +425,7 @@ Phaser.StateManager.prototype = {
418425

419426
if (this._created && this.onPausedCallback)
420427
{
421-
this.onPausedCallback.call(this.callbackContext, this.game, true);
428+
this.onPausedCallback.call(this.callbackContext, this.game);
422429
}
423430

424431
},
@@ -429,9 +436,9 @@ Phaser.StateManager.prototype = {
429436
*/
430437
resume: function () {
431438

432-
if (this._created && this.onre)
439+
if (this._created && this.onResumedCallback)
433440
{
434-
this.onPausedCallback.call(this.callbackContext, this.game, false);
441+
this.onResumedCallback.call(this.callbackContext, this.game);
435442
}
436443

437444
},
@@ -518,6 +525,7 @@ Phaser.StateManager.prototype = {
518525
this.onUpdateCallback = null;
519526
this.onRenderCallback = null;
520527
this.onPausedCallback = null;
528+
this.onResumedCallback = null;
521529
this.onDestroyCallback = null;
522530

523531
this.game = null;

0 commit comments

Comments
 (0)