I have four scenes in my application. In the first I simply display a welcome screen with the game name and tap anywhere to continue message. This all works fine as I set the event listener in the enterScene function and un-set it in the exitScene function.
The problem is with the audio I play on that screen. in createScene I set a local var to the audio.loadSound and then do audio.play in the enter scene fucntion. This works fine and the audio plays. However, when I tap the screen and change scenes the audio continues to play in this new scene. This suggests that either exitScene isn’t being called or audio.stop() is being ignored (or just plain doesn’t work)
I’ve included my code below for the offending scene if anyone would like to tell me what I’m doing wrong as I can’t see anything obvious.
[code]
module( …, package.seeall )
local scene = storyboard.newScene()
local background
local intro
local function jacksOrbetterGame( event )
if event.phase == “ended” then
storyboard.gotoScene( “jacksOrBetter” )
return true
end
end
function scene:createScene( event )
local loaclGroup = self.view
background = display.newImage(“title.png”)
intro = audio.loadSoubd(“title.mp3”)
localGroup:insert( background )
end
function scene:enterScene( event )
storyboard.purgeScene(“stats”)
background:addEventListener(“touch”, jacksOrbetterGame )
audio.play( intro )
end
function scene:exitScene( event )
background:removeEventListener( “touch”, background )
audio.stop()
end
function scene:destroyScene( event )
end
scene:addEventListener(“createScene”, scene)
scene:addEventListener(“enterScene”, scene)
scene:addEventListener(“exitScene”, scene)
scene:addEventListener(“destroyScene”, scene)
return scene
[/code] [import]uid: 82631 topic_id: 22838 reply_id: 322838[/import]