Hey all,
I’m making a game that uses randomly generated objects, where a new one is spawned once one is used. However, since you can skip over objects by taking a different path, I also want to remove them once they go offscreen so I don’t run out if I skip too many. Here’s the code I have right now:
[lua]for m,mN in ipairs(nodes) do
if mN.x < -game.x then --game.x is a negative value which shifts all game objects to the left
–this tests to see if objects have shifted offscreen
nodes:remove(m) --nodes is the group of objects
newRandomNode(lData[levNum]) --makes a new object
end
end[/lua]
And yes, before you ask, I tried seeing if x < 0, but the x-value of the objects remains constant, it’s just the game group (or you can think of it as the camera) that shifts.
Thanks in advance. [import]uid: 16445 topic_id: 11639 reply_id: 311639[/import]