Created
October 13, 2012 04:28
-
-
Save AngeloYazar/3883221 to your computer and use it in GitHub Desktop.
Sort a Corona SDK display group by y value.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local function depthSort( displayGroup ) | |
local objects = {} | |
for i=1,displayGroup.numChildren do objects[#objects+1] = {displayGroup[i].y, displayGroup[i]} end | |
table.sort( objects, function(a,b) return a[1]<b[1] end ) | |
for i=1,#objects do displayGroup:insert( objects[i][2] ) end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment