Skip to content

Commit 44a0813

Browse files
committed
[feat] scene.run can now pass data to .wake and .resume if it needs to invoke those methods
update javadoc for scene and scene systems
1 parent 734c011 commit 44a0813

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

src/scene/SceneManager.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ var SceneManager = new Class({
140140
});
141141
}
142142
}
143-
143+
144144
game.events.once('ready', this.bootQueue, this);
145145
},
146146

@@ -1011,7 +1011,7 @@ var SceneManager = new Class({
10111011

10121012
/**
10131013
* Runs the given Scene, but does not change the state of this Scene.
1014-
*
1014+
*
10151015
* If the given Scene is paused, it will resume it. If sleeping, it will wake it.
10161016
* If not running at all, it will be started.
10171017
*
@@ -1022,7 +1022,7 @@ var SceneManager = new Class({
10221022
* @since 3.10.0
10231023
*
10241024
* @param {string} key - The Scene to run.
1025-
* @param {object} [data] - A data object that will be passed to the Scene that is run _only if the Scene isn't asleep or paused_.
1025+
* @param {object} [data] - A data object that will be passed to the Scene on start, wake, or resume.
10261026
*
10271027
* @return {Phaser.Scenes.SceneManager} This Scene Manager.
10281028
*/
@@ -1038,12 +1038,12 @@ var SceneManager = new Class({
10381038
if (scene.sys.isSleeping())
10391039
{
10401040
// Sleeping?
1041-
scene.sys.wake();
1041+
scene.sys.wake(data);
10421042
}
10431043
else if (scene.sys.isBooted && !scene.sys.isActive())
10441044
{
10451045
// Paused?
1046-
scene.sys.resume();
1046+
scene.sys.resume(data);
10471047
}
10481048
else
10491049
{

src/scene/Systems.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ var Systems = new Class({
211211

212212
/**
213213
* The Scene Update function.
214-
*
214+
*
215215
* This starts out as NOOP during init, preload and create, and at the end of create
216216
* it swaps to be whatever the Scene.update function is.
217217
*
@@ -368,17 +368,19 @@ var Systems = new Class({
368368
* @method Phaser.Scenes.Systems#resume
369369
* @since 3.0.0
370370
*
371+
* @param {object} [data] - A data object that will be passed on the 'resume' event.
372+
*
371373
* @return {Phaser.Scenes.Systems} This Systems object.
372374
*/
373-
resume: function ()
375+
resume: function (data)
374376
{
375377
if (!this.settings.active)
376378
{
377379
this.settings.status = CONST.RUNNING;
378380

379381
this.settings.active = true;
380382

381-
this.events.emit('resume', this);
383+
this.events.emit('resume', this, data);
382384
}
383385

384386
return this;
@@ -415,9 +417,11 @@ var Systems = new Class({
415417
* @method Phaser.Scenes.Systems#wake
416418
* @since 3.0.0
417419
*
420+
* @param {object} [data] - A data object that will be passed on the 'wake' event.
421+
*
418422
* @return {Phaser.Scenes.Systems} This Systems object.
419423
*/
420-
wake: function ()
424+
wake: function (data)
421425
{
422426
var settings = this.settings;
423427

@@ -426,7 +430,7 @@ var Systems = new Class({
426430
settings.active = true;
427431
settings.visible = true;
428432

429-
this.events.emit('wake', this);
433+
this.events.emit('wake', this, data);
430434

431435
if (settings.isTransition)
432436
{

0 commit comments

Comments
 (0)