mirror of
https://github.com/photonstorm/phaser
synced 2024-11-22 20:53:39 +00:00
Add some helper methods for changing rendering order
This commit is contained in:
parent
e1d23b98c0
commit
a2702fd795
1 changed files with 92 additions and 0 deletions
|
@ -12,6 +12,8 @@
|
|||
* @since 3.0.0
|
||||
*/
|
||||
|
||||
var ArrayUtils = require('../../utils/array');
|
||||
|
||||
var Depth = {
|
||||
|
||||
/**
|
||||
|
@ -83,6 +85,96 @@ var Depth = {
|
|||
|
||||
this.depth = value;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Bring this Game Object to top of display list.
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.Depth#bringMeToTop
|
||||
* @since 3.80.2
|
||||
* @return {this} This Game Object instance.
|
||||
*/
|
||||
bringMeToTop: function()
|
||||
{
|
||||
var list = (this.parentContainer) ? gameObject.parentContainer : this.displayList.list;
|
||||
|
||||
if (!list)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
ArrayUtils.BringToTop(list, this);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Send this Game Object to bottom of display list.
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.Depth#sendMeToBack
|
||||
* @since 3.80.2
|
||||
* @return {this} This Game Object instance.
|
||||
*/
|
||||
sendMeToBack: function()
|
||||
{
|
||||
var list = (this.parentContainer) ? gameObject.parentContainer : this.displayList.list;
|
||||
|
||||
if (!list)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
ArrayUtils.SendToBack(list, this);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Move this Game Object below another Game Object.
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.Depth#moveMyDepthBelow
|
||||
* @since 3.80.2
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - Move this Game Object below this Game Object.
|
||||
*
|
||||
* @return {this} This Game Object instance.
|
||||
*/
|
||||
moveMyDepthBelow: function(gameObject)
|
||||
{
|
||||
var list = (this.parentContainer) ? gameObject.parentContainer : this.displayList.list;
|
||||
|
||||
if (!list)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
ArrayUtils.MoveBelow(list, this, gameObject);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Move this Game Object above another Game Object.
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.Depth#moveMyDepthAbove
|
||||
* @since 3.80.2
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - Move this Game Object above this Game Object.
|
||||
*
|
||||
* @return {this} This Game Object instance.
|
||||
*/
|
||||
moveMyDepthAbove: function(gameObject)
|
||||
{
|
||||
var list = (this.parentContainer) ? gameObject.parentContainer : this.displayList.list;
|
||||
|
||||
if (!list)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
ArrayUtils.MoveAbove(list, this, gameObject);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue