So I was trying to make a game where you tap one object and that object disappears and then a new one shows up. After tapping the first object that spawns and it disappearing, the second object spawns, as planned, but it does not register when I “touch” it. Here’s the code I think is causing it, I just don’t know why or how.
function spawnobj()
obj = display.newImageRect(“obj.png”, 175, 175)
obj.y = 800
obj.x = Random
physics.addBody(obj, “dynamic”, {density=0.01, friction=0.0, bounce=01.0, radius=40});
end
local function removeobj()
obj:removeSelf();
spawnobj()
end
spawnobj()
obj:addEventListener(“touch”, removeobj);
Thanks!