Class: DisplayList

Phaser.GameObjects. DisplayList

The Display List plugin.

Display Lists belong to a Scene and maintain the list of Game Objects to render every frame.

Some of these Game Objects may also be part of the Scene's Update List, for updating.


new DisplayList(scene)

Parameters:
Name Type Description
scene Phaser.Scene

The Scene that this Display List belongs to.

Since: 3.0.0
Source: src/gameobjects/DisplayList.js (Line 12)

Extends

Members


scene :Phaser.Scene

The Scene that this Display List belongs to.

Type:
Since: 3.0.0
Source: src/gameobjects/DisplayList.js (Line 48)

sortChildrenFlag :boolean

The flag the determines whether Game Objects should be sorted when depthSort() is called.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • false
Source: src/gameobjects/DisplayList.js (Line 38)

systems :Phaser.Scenes.Systems

The Scene's Systems.

Type:
Since: 3.0.0
Source: src/gameobjects/DisplayList.js (Line 57)

Methods


depthSort()

Immediately sorts the display list if the flag is set.

Since: 3.0.0
Source: src/gameobjects/DisplayList.js (Line 108)

getChildren()

All members of the group.

Since: 3.12.0
Source: src/gameobjects/DisplayList.js (Line 179)
Returns:

The group members.

Type
Array.<Phaser.GameObjects.GameObject>

getTopGameObject(gameObjects)

Get the top-most Game Object in the given array of Game Objects, after sorting it.

Note that the given array is sorted in place, even though it isn't returned directly it will still be updated.

Parameters:
Name Type Description
gameObjects Array.<Phaser.GameObjects.GameObject>

The array of Game Objects.

Since: 3.0.0
Source: src/gameobjects/DisplayList.js (Line 160)
Returns:

The top-most Game Object in the array of Game Objects.

Type
Phaser.GameObjects.GameObject

queueDepthSort()

Force a sort of the display list on the next call to depthSort.

Since: 3.0.0
Source: src/gameobjects/DisplayList.js (Line 97)

sortByDepth(childA, childB)

Compare the depth of two Game Objects.

Parameters:
Name Type Description
childA Phaser.GameObjects.GameObject

The first Game Object.

childB Phaser.GameObjects.GameObject

The second Game Object.

Since: 3.0.0
Source: src/gameobjects/DisplayList.js (Line 124)
Returns:

The difference between the depths of each Game Object.

Type
integer

sortGameObjects(gameObjects)

Given an array of Game Objects, sort the array and return it, so that
the objects are in index order with the lowest at the bottom.

Parameters:
Name Type Description
gameObjects Array.<Phaser.GameObjects.GameObject>

The array of Game Objects to sort.

Since: 3.0.0
Source: src/gameobjects/DisplayList.js (Line 140)
Returns:

The sorted array of Game Objects.

Type
array