Hey guys how do I make it so when a button is released it will destroy previous text and display new text when the other is destoryed. It displays the right stuff but it stays their I want it so it will destroy itself then display new text. My code Below
_----------------------------------------------------------------------------------------
– main.lua
– code below is acutally from local score = require(“score”)
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 function onObjectTouch( event )
if event.phase == “began” then
print( "Touch event began on: " )
local price = display.newText(math.random(100,10000),50,50,native.systemFont,16)
price:setTextColor(1,0,0)
end
return true
end
newcard:addEventListener( “touch”, onObjectTouch )_