I go from menu.lua to game.lua using gotoscene. At the end of game.lua I transition from game.lua to menu.lua again. Under scene:show in menu.lua I remove the game scene. When I then move back to game.lua everything in scene:show is repeated twice. scene:create is still only once.
Any idea why this would be?
Thank you.
function scene:show( event )
local sceneGroup = self.view
local phase = event.phase
if ( phase == "will" ) then
print("does this print once or twice?")
-- Code here runs when the scene is still off screen (but is about to come on screen)
elseif ( phase == "did" ) then
physics.start()
gameLoopTimer = timer.performWithDelay( 1750, gameLoop, 0 )
-- Start the music!
audio.play( musicTrack, { channel=1, loops=-1 } )
audio.setVolume( 0, { channel=1 } )
-- Code here runs when the scene is entirely on screen
end
end
composer.gotoscene(game.lua) is called by a tap one of the multiple objects created by this the menuDrawer function that is called during the create phase.
local function menuDrawer()
....
for i = 1, #menuLetters, 1 do
....
local Letterbackground = display.newRoundedRect(sceneGroup, Letterbackgroundx, Letterbackgroundy, 100, 125, 10 )
....
Letterbackground:addEventListener( "tap", gotoGame )
end
The EventListener is never removed as there are only defined by the local variable within the function. Would this cause the problem?
If you need any more information please let me know.