Namespace: Depth

Phaser.GameObjects.Components. Depth

Provides methods used for setting the depth of a Game Object. Should be applied as a mixin and not used directly.

Since: 3.0.0
Source: src/gameobjects/components/Depth.js (Line 7)

Members


depth :number

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 default depth is zero. 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.

Type:
  • number
Since: 3.0.0
Source: src/gameobjects/components/Depth.js (Line 28)

Methods


setDepth(value)

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 default depth is zero. 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.

Parameters:
Name Type Description
value integer

The depth of this Game Object.

Since: 3.0.0
Source: src/gameobjects/components/Depth.js (Line 58)
Returns:

This Game Object instance.

Type
Phaser.GameObjects.Components.Depth