0
我想通过触摸它们来销毁物体,这些物体随机在屏幕上每1秒产生一次。 我写了一些东西,但它只销毁了第一个产生的对象。 我很喜欢这个东西,有人可以帮助我吗? 我写了这个代码:(雷霆是我的对象)摧毁触摸产生的物体Corona SDK
local thunder = display.newImageRect("thunder_icon.png",100,100)
thunder.x = larghezza/2
thunder.y = altezza/2
local spawnTimer
local function myToccoListener(event)
display.remove(thunder)
return true
end
local spawn = function()
local xCoord = math.random(display.contentWidth * 0, display.contentWidth * 1.0)
local thunder = display.newImageRect("thunder_icon.png",100,100)
thunder.x = xCoord
thunder.y = 50
thunder:addEventListener("touch", myToccoListener)
end
spawnTimer = timer.performWithDelay(1000, spawn, -1)