mirror of
https://github.com/photonstorm/phaser
synced 2024-11-22 12:43:26 +00:00
SceneManager.moveAbove and moveBelow added.
SceneManager.moveAbove will move a Scene to be directly above another Scene in the Scenes list. This is also exposed in the ScenePlugin. SceneManager.moveBelow will move a Scene to be directly below another Scene in the Scenes list. This is also exposed in the ScenePlugin.
This commit is contained in:
parent
7341d7a6cf
commit
95d85576c9
3 changed files with 140 additions and 4 deletions
|
@ -13,6 +13,8 @@
|
|||
* GameObject.setInteractive has a new boolean argument `dropZone` which will allow you to set the object as being a drop zone right from the method.
|
||||
* Sprites can now be drop zones and have other Game Objects dragged onto them as targets.
|
||||
* The SceneManager has a new method: `remove` which allows you to remove and destroy a Scene, freeing up the Scene key for use by future scenes and potentially clearing the Scene from active memory for gc.
|
||||
* SceneManager.moveAbove will move a Scene to be directly above another Scene in the Scenes list. This is also exposed in the ScenePlugin.
|
||||
* SceneManager.moveBelow will move a Scene to be directly below another Scene in the Scenes list. This is also exposed in the ScenePlugin.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
|
|
|
@ -1024,7 +1024,7 @@ var SceneManager = new Class({
|
|||
* @method Phaser.Scenes.SceneManager#bringToTop
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string|Phaser.Scene} scene - [description]
|
||||
* @param {string|Phaser.Scene} key - [description]
|
||||
*
|
||||
* @return {Phaser.Scenes.SceneManager} [description]
|
||||
*/
|
||||
|
@ -1056,7 +1056,7 @@ var SceneManager = new Class({
|
|||
* @method Phaser.Scenes.SceneManager#sendToBack
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string|Phaser.Scene} scene - [description]
|
||||
* @param {string|Phaser.Scene} key - [description]
|
||||
*
|
||||
* @return {Phaser.Scenes.SceneManager} [description]
|
||||
*/
|
||||
|
@ -1088,7 +1088,7 @@ var SceneManager = new Class({
|
|||
* @method Phaser.Scenes.SceneManager#moveDown
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string|Phaser.Scene} scene - [description]
|
||||
* @param {string|Phaser.Scene} key - [description]
|
||||
*
|
||||
* @return {Phaser.Scenes.SceneManager} [description]
|
||||
*/
|
||||
|
@ -1122,7 +1122,7 @@ var SceneManager = new Class({
|
|||
* @method Phaser.Scenes.SceneManager#moveUp
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string|Phaser.Scene} scene - [description]
|
||||
* @param {string|Phaser.Scene} key - [description]
|
||||
*
|
||||
* @return {Phaser.Scenes.SceneManager} [description]
|
||||
*/
|
||||
|
@ -1150,6 +1150,92 @@ var SceneManager = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Moves a Scene so it is immediately above another Scene in the Scenes list.
|
||||
* This means it will render over the top of the other Scene.
|
||||
*
|
||||
* @method Phaser.Scenes.SceneManager#moveAbove
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @param {string|Phaser.Scene} keyA - The Scene that Scene B will be moved above.
|
||||
* @param {string|Phaser.Scene} keyB - The Scene to be moved.
|
||||
*
|
||||
* @return {Phaser.Scenes.SceneManager} [description]
|
||||
*/
|
||||
moveAbove: function (keyA, keyB)
|
||||
{
|
||||
if (keyA === keyB)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
if (this._processing)
|
||||
{
|
||||
this._queue.push({ op: 'moveAbove', keyA: keyA, keyB: keyB });
|
||||
}
|
||||
else
|
||||
{
|
||||
var indexA = this.getIndex(keyA);
|
||||
var indexB = this.getIndex(keyB);
|
||||
|
||||
if (indexA > indexB && indexA !== -1 && indexB !== -1)
|
||||
{
|
||||
var tempScene = this.getAt(indexB);
|
||||
|
||||
// Remove
|
||||
this.scenes.splice(indexB, 1);
|
||||
|
||||
// Add in new location
|
||||
this.scenes.splice(indexA, 0, tempScene);
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Moves a Scene so it is immediately below another Scene in the Scenes list.
|
||||
* This means it will render behind the other Scene.
|
||||
*
|
||||
* @method Phaser.Scenes.SceneManager#moveBelow
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @param {string|Phaser.Scene} keyA - The Scene that Scene B will be moved above.
|
||||
* @param {string|Phaser.Scene} keyB - The Scene to be moved.
|
||||
*
|
||||
* @return {Phaser.Scenes.SceneManager} [description]
|
||||
*/
|
||||
moveBelow: function (keyA, keyB)
|
||||
{
|
||||
if (keyA === keyB)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
if (this._processing)
|
||||
{
|
||||
this._queue.push({ op: 'moveBelow', keyA: keyA, keyB: keyB });
|
||||
}
|
||||
else
|
||||
{
|
||||
var indexA = this.getIndex(keyA);
|
||||
var indexB = this.getIndex(keyB);
|
||||
|
||||
if (indexA < indexB && indexA !== -1 && indexB !== -1)
|
||||
{
|
||||
var tempScene = this.getAt(indexB);
|
||||
|
||||
// Remove
|
||||
this.scenes.splice(indexB, 1);
|
||||
|
||||
// Add in new location
|
||||
this.scenes.splice(indexA, 0, tempScene);
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
queueOp: function (op, keyA, keyB)
|
||||
{
|
||||
this._queue.push({ op: op, keyA: keyA, keyB: keyB });
|
||||
|
|
|
@ -400,6 +400,54 @@ var ScenePlugin = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Swaps the position of two scenes in the Scenes list, so that Scene B is directly above Scene A.
|
||||
* This controls the order in which they are rendered and updated.
|
||||
*
|
||||
* @method Phaser.Scenes.ScenePlugin#moveAbove
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @param {string} keyA - The Scene that Scene B will be moved to be above.
|
||||
* @param {string} [keyB] - The Scene to be moved. If none is given it defaults to this Scene.
|
||||
*
|
||||
* @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object.
|
||||
*/
|
||||
moveAbove: function (keyA, keyB)
|
||||
{
|
||||
if (keyB === undefined) { keyB = this.key; }
|
||||
|
||||
if (keyA !== keyB)
|
||||
{
|
||||
this.manager.moveAbove(keyA, keyB);
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Swaps the position of two scenes in the Scenes list, so that Scene B is directly below Scene A.
|
||||
* This controls the order in which they are rendered and updated.
|
||||
*
|
||||
* @method Phaser.Scenes.ScenePlugin#moveBelow
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @param {string} keyA - The Scene that Scene B will be moved to be below.
|
||||
* @param {string} [keyB] - The Scene to be moved. If none is given it defaults to this Scene.
|
||||
*
|
||||
* @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object.
|
||||
*/
|
||||
moveBelow: function (keyA, keyB)
|
||||
{
|
||||
if (keyB === undefined) { keyB = this.key; }
|
||||
|
||||
if (keyA !== keyB)
|
||||
{
|
||||
this.manager.moveBelow(keyA, keyB);
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes a Scene from the SceneManager.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue