File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -312,6 +312,49 @@ var GameObject = new Class({
312312 return ( GameObject . RENDER_MASK === this . renderFlags ) ;
313313 } ,
314314
315+ /**
316+ * Returns an array containing the display list index of either this Game Object, or if it has one,
317+ * its parent Container. It then iterates up through all of the parent containers until it hits the
318+ * root of the display list (which is index 0 in the returned array).
319+ *
320+ * Used internally by the InputPlugin but also useful if you wish to find out the display depth of
321+ * this Game Object and all of its ancestors.
322+ *
323+ * @method Phaser.GameObjects.GameObject#getIndexList
324+ * @since 3.4.0
325+ *
326+ * @return {integer[] } An array of display list position indexes.
327+ */
328+ getIndexList : function ( )
329+ {
330+ var child = this ;
331+ var parent = this . parentContainer ;
332+
333+ var indexes = [ ] ;
334+
335+ while ( parent )
336+ {
337+ // indexes.unshift([parent.getIndex(child), parent.name]);
338+ indexes . unshift ( parent . getIndex ( child ) ) ;
339+
340+ child = parent ;
341+
342+ if ( ! parent . parentContainer )
343+ {
344+ break ;
345+ }
346+ else
347+ {
348+ parent = parent . parentContainer ;
349+ }
350+ }
351+
352+ // indexes.unshift([this.scene.sys.displayList.getIndex(child), 'root']);
353+ indexes . unshift ( this . scene . sys . displayList . getIndex ( child ) ) ;
354+
355+ return indexes ;
356+ } ,
357+
315358 /**
316359 * Destroys this Game Object removing it from the Display List and Update List and
317360 * severing all ties to parent resources.
You can’t perform that action at this time.
0 commit comments