I posted two previous questions asking for help with my Ball touch error and I got answers but none of them helped me . So can someone please help me . When I touch the ball nothing happens but I don’t get any errors or anything the balls just don’t disappear . Can someone please help me make the balls disappear when the user touches them ?
local Balls = {} local numberBall = 3 local function spawnBall() for i = 1 , numberBall do Ballss = display.newCircle(60, 60, 13) Ballss.x = math.random(10, 300); Ballss.y = 50; Ballss:setFillColor( 0, 5, 0 ) transition.to( Ballss, { time=math.random(4000,8000), x=math.random(-10,100) , y=600, onComplete=clearBall } ); physics.addBody( Ballss, "dynamic", { density=0.1, bounce=0.1, friction=0.1, radius=0 } ); Runtime:addEventListener("touch", Ballss) end end spawnBall() timerrr =timer.performWithDelay( 3000, spawnBall, 0 ) --fire every 10 seconds local function handleTouch(event) if ( event.phase == "ended" ) then for i=#Balls, 1, -1 do local Ballss = table.remove(Ballss, i) Runtime:addEventListener("touch", Balls) if Ballss ~= nil then display.remove(Ballss) Ballss = nil end end end end function timerDown() timeLimit = timeLimit-1 timeLeft.text = timeLimit if(timeLimit == 0)then timer.cancel(timerr) display.remove(timeLeft) display.remove(Ballss) timer.cancel(timerrr) composer.gotoScene("restart", "fade", 300) return true end end timerr = timer.performWithDelay(1000,timerDown,timeLimit) function scene:show(event) end function scene:hide(event) if Balls and #Balls \> 0 then for i=1, #Balls do end end composer.removeScene( "restart" ) end