So, I’m building an app with multiple scenes and noticed that the destroy function isn’t firing when removeScene is called. I did some looking through the code and the forums to try and find something. That didn’t work. So, I decided to remove everything from the code but the bare minimum to test scene changes. I still can’t figure out why the destroy function isn’t working. If what I stated was unclear at all, I’d be more than happy to clarify, and any help is very appreciated. Here’s the code:
local composer = require( "composer" )
local scene = composer.newScene()
local function bark( )
composer.gotoScene( "levels.gameOver", { time=800, effect="crossFade" } )
end
function scene:create( event )
print("1")
local sceneGroup = self.view
local barkArrow = display.newRect(sceneGroup,display.contentCenterX, display.contentCenterY,40,40)
barkArrow:addEventListener("touch", bark)
end
function scene:show( event )
print("2")
local sceneGroup = self.view
local phase = event.phase
if ( phase == "will" ) then
elseif ( phase == "did" ) then
end
end
function scene:hide( event )
print("3")
local sceneGroup = self.view
local phase = event.phase
if ( phase == "will" ) then
elseif ( phase == "did" ) then
composer.removeScene( "level1" )
end
end
function scene:destroy( event )
print("4")
local sceneGroup = self.view
end
scene:addEventListener( "create", scene )
scene:addEventListener( "show", scene )
scene:addEventListener( "hide", scene )
scene:addEventListener( "destroy", scene )
return scene