File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11var CHECKSUM = {
2- build : 'c4ee8ed0-6c88 -11e7-9662-435d7268dd6f '
2+ build : '98dca120-6d40 -11e7-8ba2-2f8841c28191 '
33} ;
44module . exports = CHECKSUM ;
Original file line number Diff line number Diff line change @@ -83,6 +83,45 @@ var DisplayList = new Class({
8383 return this . list . indexOf ( child ) ;
8484 } ,
8585
86+ // Given an array of Game Objects, sort the array and return it,
87+ // so that the objects are in index order with the lowest at the bottom.
88+ sortGameObjects : function ( gameObjects )
89+ {
90+ if ( gameObjects === undefined ) { gameObjects = this . list ; }
91+
92+ this . scene . sys . depthSort ( ) ;
93+
94+ return gameObjects . sort ( this . sortIndexHandler . bind ( this ) ) ;
95+ } ,
96+
97+ getTopGameObject : function ( gameObjects )
98+ {
99+ this . sortGameObjects ( gameObjects ) ;
100+
101+ return gameObjects [ gameObjects . length - 1 ] ;
102+ } ,
103+
104+ // Return the child lowest down the display list (with the smallest index)
105+ sortIndexHandler : function ( childA , childB )
106+ {
107+ // The lower the index, the lower down the display list they are
108+ var indexA = this . getIndex ( childA ) ;
109+ var indexB = this . getIndex ( childB ) ;
110+
111+ if ( indexA < indexB )
112+ {
113+ return - 1 ;
114+ }
115+ else if ( indexA > indexB )
116+ {
117+ return 1 ;
118+ }
119+
120+ // Technically this shouldn't happen, but if the GO wasn't part of this display list then it'll
121+ // have an index of -1, so in some cases it can
122+ return 0 ;
123+ } ,
124+
86125 /**
87126 * Gets the first item from the set based on the property strictly equaling the value given.
88127 * Returns null if not found.
You can’t perform that action at this time.
0 commit comments