I have a timer which calls a function that creates objects off screen, moves them onto the screen, and then removes them.
Objects are moved with transition.to and then in onComplete I am doing display.remove. Here is a code snippet:
local objects = {} local function createObject(position, spd) print("object count is: " .. #objects) local tmp = display.newImageRect(dsp\_grp, "sprites/object.png", 211, 244) tmp.x, tmp.y = position.startX, position.startY object\_transitions[#object\_transitions + 1] = transition.to(tmp, {time = spd, x = position.endX, onComplete = display.remove}) objects[#objects + 1] = tmp end timer.performWithDelay(frequency, function() createObject(position, speed) end, -1)
My question is: Why is #objects always growing every time I call the print statement? I thought after display.remove the object no longer exists in the table so the table size shouldn’t keep growing?
Can anyone point out what I am missing?