So if you watched the video above you see that its duplicating the objects after like 4 or so seconds…
heres the code maybe you can find my problem cause i cant seem to figure it out thnks!
local composer = require( "composer" ) local scene = composer.newScene() local \_W = display.contentWidth local \_H = display.contentHeight local physics = require("physics" ) physics.setScale( 30 ) physics.setGravity( 0, 0 ) physics.start( ) physics.setDrawMode( "hybrid" ) function scene:create( event ) local sceneGroup = self.view physics.start() ---------------------------- local BackGround = display.newImageRect("BackGround.png", 1080, 1920) return true end function scene:show(event) local sceneGroup = self.view if event.phase == "did" then ------------------------------------------- physics.start() -------------------------------------------- local floor = display.newImageRect("floor.png", 351, 32 ) floor.x = display.contentWidth \* 0.5 floor.y = 520 physics.addBody(floor, "static") floor.value = 1 ----------------------------------------------- local i = 5 local circle = {} local spawnCircles = function () local FallDown = math.random(display.contentWidth \* 0.2, display.contentWidth \* 0.8 ) circle[i] = display.newImageRect("circle.png", 31, 31 ) circle[i].x = FallDown circle[i].y = -70 physics.addBody( circle[i], "dynamic", {density = .01, friction = 0.5, bounce = 0.1 }) circle[i].gravityScale = 0.1 physics.setGravity( 0, 10 ) circle[i].collision = onCollision circle[i].value = i circle[i]:addEventListener( "collision", circle) i = i + 1 if i == 10 then -- i = 10 means 10 circles will be created in the circleTable i = 5 end end floor.collision = onCollision myTimer = timer.performWithDelay( 2000, spawnCircles, -1) --1000 is the time -------------------------------------------------------------- --------------------------------------------------------------- local onCollision = function(self,event) if event.phase == "began" then local hit = self.value local other = event.other.value if other == 1 then display.remove( circle[i] ) end end end ------------------------------------------------------------------- end return true end -- ------------------------------------------------------------------------------- -- Listener setup scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) -- ------------------------------------------------------------------------------- return scene
