Hi
I have little problem… I have a tree with fruits and I want them to fall down each after plus minus 1 sec.
so this is what I done :
local n = 600
local showOranges = function()
local fruits = display.newImage("frutit.png")
local time = n
orangeGroup:insert(fruits)
fruits.collision = floorCollision
fruits:addEventListener("collision", fruits)
theTimer7 = timer.performWithDelay(time, function()
physics.addBody(fruits, "dynamic", {density = 0.1, friction = 0.1, radius = 22, bounce = 0.2, filter = {categoryBits = 2, maskBits = 1} })
fruits:addEventListener("touch", function(event) cutFruit(fruits) end )end)
n = n + 600
end
timer.performWithDelay(1, showOranges, #orangesPositions )
Its works ok but I can not stop it. I mean if I want to stop game after 5 oranges theTimer7 is still working, ofcourse I’am canceling it.
I’am changing scene and theTimer7 is still trying to add physics body to another fruit. and I’ve got a lot errors.
I understand why but maybe is there a simple way to draw objects and then add dynamic physics and event listener one by one.
[import]uid: 13156 topic_id: 13179 reply_id: 313179[/import]
