Skip to content

Commit bf368ab

Browse files
committed
ScenePlugin.restart allows you to restart the current Scene. It's the same result as calling ScenePlugin.start without any arguments, but is more clear.
1 parent 1a3d433 commit bf368ab

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

src/scene/ScenePlugin.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,34 @@ var ScenePlugin = new Class({
121121
return this;
122122
},
123123

124+
/**
125+
* Restarts this Scene.
126+
*
127+
* @method Phaser.Scenes.ScenePlugin#restart
128+
* @since 3.4.0
129+
*
130+
* @param {object} [data] - The Scene data.
131+
*
132+
* @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object.
133+
*/
134+
restart: function (data)
135+
{
136+
var key = this.key;
137+
138+
if (this.settings.status !== CONST.RUNNING)
139+
{
140+
this.manager.queueOp('stop', key);
141+
this.manager.queueOp('start', key, data);
142+
}
143+
else
144+
{
145+
this.manager.stop(key);
146+
this.manager.start(key, data);
147+
}
148+
149+
return this;
150+
},
151+
124152
/**
125153
* Add the Scene into the Scene Manager and start it if 'autoStart' is true or the Scene config 'active' property is set.
126154
*

0 commit comments

Comments
 (0)