Hey guys how do I destroy an object then respawn it right after it is destoryed. I got it so it displays one on game startup then when you touch the button it displays a new one but it only works once. Any Help?
_local widget = require (“widget”)
local rectangle = display.newRect(160,200,275,400)
local buy = widget.newButton
{
left = -45,
top = 350,
id = “buybtn”,
label = “Buy”,
}
local newcard = widget.newButton
{
left = 160,
top = 350,
id = “newcardbtn”,
label = “New Card”,
}
local price = display.newText(math.random(100,10000),50,50,native.systemFont,16)
price:setTextColor(1,0,0)
local function onObjectTouch( event )
if event.phase == “began” then
price:removeSelf()
local price = display.newText(math.random(100,10000),50,50,native.systemFont,16)
price:setTextColor(1,0,0)
end
end
newcard:addEventListener(“touch”,onObjectTouch)_