Search code examples
luacoronasdkcorona-storyboard

Corona Storyboard doesn't remove element from previous scene


I have a scene in Corona SDK storyboard, a text. I want it that when it enters the scene, the text becomes "1" and it appears, when it exists the scene i want it disappeared so I set it to "". (an empty string) But when I get back to the scene, it remains "" and doesnt sit it to 1 again.

function scene:enterScene( event )
    local screenGroup = self.view
    storyboard.purgeScene("mainmenuscene")
    backbtn:addEventListener("touch",backbtn)
    leveltext = display.newText("1", 75, 1.7, native.systemFontBold, 20)
    leveltext:setTextColor(255,255,255)

end

and here is the exit scene function

function scene:exitScene( event )

local screenGroup = self.view -- remove touch listener for image backbtn:removeEventListener( "touch", backbtn ) leveltext = display.newText("", 75, 1.7, native.systemFontBold, 20) leveltext:setTextColor(255,255,255)

end


Solution

  • Nevermind, I fixed it. Apparently in the exit scene function I should've done leveltext:removeSelf() instead of moving it to ""