I have noticed strange bugs with display.newGroup():insert() function.
I had this function:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | function orderObjects(field) orderGroup = display.newGroup() local main_obj = {} for i = 1, field.ROWS do for k = 1, field.COLS do if field.cells[k][i].object then if field.cells[k][i].object.type ~= "main" then orderGroup:insert(orderGroup.numChildren + 1, field.cells[k][i].object.image) else main_obj = field.cells[k][i].object end end end end orderGroup:insert(orderGroup.numChildren + 1, main_obj.image) end |
I cannot comprehend the complexity you are introducing, but a simple suggestion, why do you *not* check as
1 2 3 | if main_obj.image ~= nil then -- do the inserting here end |
views:1229 update:2011/11/3 16:17:22