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.
|
|
|
|
*
|
|
|
|
* @name Phaser.GameObjects.Components.Depth
|
|
|
|
* @mixin
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-10-20 13:12:16 +00:00
|
|
|
|
|
|
|
var Depth = {
|
|
|
|
|
|
|
|
// "private" properties
|
|
|
|
_depth: 0,
|
|
|
|
|
2018-02-01 00:04:45 +00:00
|
|
|
/**
|
|
|
|
* The depth of this Game Object within the Scene.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth
|
|
|
|
* value will always render in front of one with a lower value.
|
|
|
|
*
|
|
|
|
* Setting the depth will queue a depth sort event within the Scene.
|
|
|
|
*
|
|
|
|
* @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)
|
|
|
|
{
|
2018-01-11 13:59:06 +00:00
|
|
|
this.scene.sys.queueDepthSort();
|
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.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth
|
|
|
|
* value will always render in front of one with a lower value.
|
|
|
|
*
|
|
|
|
* Setting the depth will queue a depth sort event within the Scene.
|
|
|
|
*
|
|
|
|
* @method Phaser.GameObjects.Components.Depth.setDepth
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {integer} value - The depth of this Game Object.
|
|
|
|
*
|
|
|
|
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
|
|
|
|
*/
|
2017-10-20 13:12:16 +00:00
|
|
|
setDepth: function (value)
|
|
|
|
{
|
|
|
|
if (value === undefined) { value = 0; }
|
|
|
|
|
|
|
|
this.depth = value;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = Depth;
|