Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add getDisplayList method to layer game object #7015

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions src/gameobjects/layer/Layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,38 @@ var Layer = new Class({
return this;
},

/**
* Returns a reference to the underlying display list _array_ that contains this Game Object,
* which will be either the Scene's Display List or the internal list belonging
* to its parent Container, if it has one.
*
* If this Game Object is not on a display list or in a container, it will return `null`.
*
* You should be very careful with this method, and understand that it returns a direct reference to the
* internal array used by the Display List. Mutating this array directly can cause all kinds of subtle
* and difficult to debug issues in your game.
*
* @method Phaser.GameObjects.Layer#getDisplayList
* @since 3.85.0
*
* @return {?Phaser.GameObjects.GameObject[]} The internal Display List array of Game Objects, or `null`.
*/
getDisplayList: function ()
{
var list = null;

if (this.parentContainer)
{
list = this.parentContainer.list;
}
else if (this.displayList)
{
list = this.displayList.list;
}

return list;
},

/**
* Destroys this Layer removing it from the Display List and Update List and
* severing all ties to parent resources.
Expand Down