I cant remove object (the “icon”, “icon2”) after it spawns
[lua]local mRandom = math.random
local mABs = math.abs
local objects = { “icon”, “icon2” }
local function spawnObject ()
local objIdx = mRandom(#objects)
local objName = objects[objIdx]
local ab = display.newImage (""…objName…".png")
ab.x = mRandom(40,300)
ab.y = display.contentCenterY
physics.addBody (ab, “dynamic”)
end
timer.performWithDelay ( 300, spawnObject, 3)
local btn = display.newRect ( 10, 10, 70, 70)
btn.x = display.contentCenterX - 50
btn.y = display.contentCenterY - -180
function removeicon (event)
if event.phase == “ended” then
display.remove ( ab )
end
end
btn:addEventListener (“touch”, removeicon)[/lua]