Hi, so I am trying to make a function that will delete these "tiles" from the mapGroup if they get too low or don't belong there based on my algorithm.
So I'm using this at the moment to delete the tiles if they get too low
for i = mapGroup.numChildren, 1, -1 do if gameover == false then if hasCollided(mapGroup[i], character) then end_game() end if hasCollided(mapGroup[i], deleteSpace) then mapGroup:remove(i) mapGroup[i] = nil end end end
And you think that it would work good except that it leaves these "ghost" tiles that take up an index value. So I end up with 200+ tiles in the displayGroup that arn't actually there and cant do anything. Would anyone know why these empty "tiles" are left over?
Also when I try another way of removing the tiles when they get too low like
for d = mapGroup.numChildren, 1, -1 do if mapGroup[d].y > 1400 then mapGroup:remove(d) mapGroup[d] = nil end end
It only works on the first loop of the for loop but once it is called again it does not remove the tiles. It only seems to remove them on the first time it is run but not after that. Thanks if you can help!