2018-02-12 16:01:20 +00:00
|
|
|
/**
|
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
2022-02-28 14:29:51 +00:00
|
|
|
* @copyright 2022 Photon Storm Ltd.
|
2019-05-10 15:15:04 +00:00
|
|
|
* @license {@link https://opensource.org/licenses/MIT|MIT License}
|
2018-02-12 16:01:20 +00:00
|
|
|
*/
|
|
|
|
|
2018-02-01 00:04:45 +00:00
|
|
|
/**
|
|
|
|
* Provides methods used for setting the depth of a Game Object.
|
|
|
|
* Should be applied as a mixin and not used directly.
|
2020-11-26 16:20:54 +00:00
|
|
|
*
|
2019-02-12 12:48:41 +00:00
|
|
|
* @namespace Phaser.GameObjects.Components.Depth
|
2018-02-01 00:04:45 +00:00
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-10-20 13:12:16 +00:00
|
|
|
|
|
|
|
var Depth = {
|
|
|
|
|
2018-03-29 12:48:14 +00:00
|
|
|
/**
|
|
|
|
* Private internal value. Holds the depth of the Game Object.
|
2020-11-26 16:20:54 +00:00
|
|
|
*
|
2018-03-29 12:48:14 +00:00
|
|
|
* @name Phaser.GameObjects.Components.Depth#_depth
|
2020-11-23 10:22:13 +00:00
|
|
|
* @type {number}
|
2018-03-29 12:48:14 +00:00
|
|
|
* @private
|
|
|
|
* @default 0
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-10-20 13:12:16 +00:00
|
|
|
_depth: 0,
|
|
|
|
|
2018-02-01 00:04:45 +00:00
|
|
|
/**
|
2022-05-06 14:16:41 +00:00
|
|
|
* The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type.
|
2020-11-26 16:20:54 +00:00
|
|
|
*
|
2018-02-01 00:04:45 +00:00
|
|
|
* The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order
|
|
|
|
* of Game Objects, without actually moving their position in the display list.
|
|
|
|
*
|
2020-05-25 16:20:42 +00:00
|
|
|
* The default depth is zero. A Game Object with a higher depth
|
2018-02-01 00:04:45 +00:00
|
|
|
* value will always render in front of one with a lower value.
|
|
|
|
*
|
|
|
|
* Setting the depth will queue a depth sort event within the Scene.
|
2020-11-26 16:20:54 +00:00
|
|
|
*
|
2018-02-01 00:04:45 +00:00
|
|
|
* @name Phaser.GameObjects.Components.Depth#depth
|
|
|
|
* @type {number}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-10-20 13:12:16 +00:00
|
|
|
depth: {
|
|
|
|
|
|
|
|
get: function ()
|
|
|
|
{
|
|
|
|
return this._depth;
|
|
|
|
},
|
|
|
|
|
|
|
|
set: function (value)
|
|
|
|
{
|
2020-11-27 11:13:59 +00:00
|
|
|
if (this.displayList)
|
2020-11-26 16:20:54 +00:00
|
|
|
{
|
2020-11-27 11:13:59 +00:00
|
|
|
this.displayList.queueDepthSort();
|
2020-11-26 16:20:54 +00:00
|
|
|
}
|
|
|
|
|
2017-10-20 13:12:16 +00:00
|
|
|
this._depth = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
2018-02-01 00:04:45 +00:00
|
|
|
/**
|
|
|
|
* The depth of this Game Object within the Scene.
|
2020-11-26 16:20:54 +00:00
|
|
|
*
|
2018-02-01 00:04:45 +00:00
|
|
|
* The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order
|
|
|
|
* of Game Objects, without actually moving their position in the display list.
|
|
|
|
*
|
2020-05-25 16:20:42 +00:00
|
|
|
* The default depth is zero. A Game Object with a higher depth
|
2018-02-01 00:04:45 +00:00
|
|
|
* value will always render in front of one with a lower value.
|
|
|
|
*
|
|
|
|
* Setting the depth will queue a depth sort event within the Scene.
|
2020-11-26 16:20:54 +00:00
|
|
|
*
|
2018-02-01 01:36:52 +00:00
|
|
|
* @method Phaser.GameObjects.Components.Depth#setDepth
|
2018-02-01 00:04:45 +00:00
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2022-05-06 14:16:41 +00:00
|
|
|
* @param {number} value - The depth of this Game Object. Ensure this value is only ever a number data-type.
|
2020-11-26 16:20:54 +00:00
|
|
|
*
|
2018-05-22 04:46:26 +00:00
|
|
|
* @return {this} This Game Object instance.
|
2018-02-01 00:04:45 +00:00
|
|
|
*/
|
2017-10-20 13:12:16 +00:00
|
|
|
setDepth: function (value)
|
|
|
|
{
|
|
|
|
if (value === undefined) { value = 0; }
|
|
|
|
|
|
|
|
this.depth = value;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = Depth;
|