Skip to content

Commit a993251

Browse files
committed
ScenePlugin.swapPosition now allows you to use it to swap the positions of any two Scenes. Before the change it only allowed you to swap the position of the calling Scene and another one, but a new optional keyB argument opens this up.
1 parent 4de9690 commit a993251

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

src/scene/ScenePlugin.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -377,20 +377,24 @@ var ScenePlugin = new Class({
377377
},
378378

379379
/**
380-
* [description]
380+
* Swaps the position of two scenes in the Scenes list.
381+
* This controls the order in which they are rendered and updated.
381382
*
382383
* @method Phaser.Scenes.ScenePlugin#swapPosition
383-
* @since 3.0.0
384+
* @since 3.2.0
384385
*
385-
* @param {string} key - [description]
386+
* @param {string} keyA - The first Scene to swap.
387+
* @param {string} [keyB] - The second Scene to swap. If none is given it defaults to this Scene.
386388
*
387389
* @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object.
388390
*/
389-
swapPosition: function (key)
391+
swapPosition: function (keyA, keyB)
390392
{
391-
if (key && key !== this.key)
393+
if (keyB === undefined) { keyB = this.key; }
394+
395+
if (keyA !== keyB)
392396
{
393-
this.manager.swapPosition(this.key, key);
397+
this.manager.swapPosition(keyA, keyB);
394398
}
395399

396400
return this;

0 commit comments

Comments
 (0)