Hi my objects are not removing after leaving the scene, i have tried to purging and removing the scene, but the objects will just keep on spawning in a other scene?
local badclout1 = {} local bad1Group = display.newGroup() local function spawnBC1() local badclouts1 = display.newImage("BCloud1.png") badclouts1.x = math.random(0, \_W) physics.addBody( badclouts1, "dynamic", { density=.1, bounce=.1, friction=.2, radius=45 } ) badclouts1.name = "BCloud1" badclouts1.bodyType = "kinematic" badclouts1.isSensor = true badclouts1.y = math.random(-100, -50) badclouts1.index = #badclout1 + 1 bad1Group:insert(badclouts1) badclouts1.rotation = math.random(-10,10) -- Rotate the object badclouts1:setLinearVelocity(0, math.random(speeda1, speedb1)) -- Drop down badclout1[badclouts1.index] = badclouts1 tmrSpawn1 = timer.performWithDelay(math.random(spawna, spawnb), spawnBC1) return badclouts1 end tmrSpawn1 = timer.performWithDelay(math.random(1000, 10000), spawnBC1) local function removeBomb() for i, v in pairs(badclout1) do if badclout1[i].y \>1000 then badclout1[i]:removeSelf() badclout1[i] = nil end end end Runtime:addEventListener("enterFrame", removeBomb)
is there something in my code that keeps it on the screen ?