mirror of
https://github.com/photonstorm/phaser
synced 2024-11-24 05:33:35 +00:00
Added getIndexList method.
This commit is contained in:
parent
38626f8556
commit
9c0c037d79
1 changed files with 43 additions and 0 deletions
|
@ -312,6 +312,49 @@ var GameObject = new Class({
|
|||
return (GameObject.RENDER_MASK === this.renderFlags);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns an array containing the display list index of either this Game Object, or if it has one,
|
||||
* its parent Container. It then iterates up through all of the parent containers until it hits the
|
||||
* root of the display list (which is index 0 in the returned array).
|
||||
*
|
||||
* Used internally by the InputPlugin but also useful if you wish to find out the display depth of
|
||||
* this Game Object and all of its ancestors.
|
||||
*
|
||||
* @method Phaser.GameObjects.GameObject#getIndexList
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @return {integer[]} An array of display list position indexes.
|
||||
*/
|
||||
getIndexList: function ()
|
||||
{
|
||||
var child = this;
|
||||
var parent = this.parentContainer;
|
||||
|
||||
var indexes = [];
|
||||
|
||||
while (parent)
|
||||
{
|
||||
// indexes.unshift([parent.getIndex(child), parent.name]);
|
||||
indexes.unshift(parent.getIndex(child));
|
||||
|
||||
child = parent;
|
||||
|
||||
if (!parent.parentContainer)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
parent = parent.parentContainer;
|
||||
}
|
||||
}
|
||||
|
||||
// indexes.unshift([this.scene.sys.displayList.getIndex(child), 'root']);
|
||||
indexes.unshift(this.scene.sys.displayList.getIndex(child));
|
||||
|
||||
return indexes;
|
||||
},
|
||||
|
||||
/**
|
||||
* Destroys this Game Object removing it from the Display List and Update List and
|
||||
* severing all ties to parent resources.
|
||||
|
|
Loading…
Reference in a new issue