is there a way to delay executing changeScene function? I have a scenario where I have to play an audio before moving to the next scene but the next scene also has an audio too. Right now, when I execute the changeScene function I get audio overlap. So, how do I complete the audio from scene1 before transitioning to scene2
example of what I have right now:
1 2 3 4 5 6 7 8 9 | local imageTouched = function ( event ) if event.phase == "began" then transition.to(circle, {time=100, xScale = 1.5, yScale = 1.5}) audio.play(soundYesYouGotIt); elseif event.phase == "ended" then transition.to(circle, {time=100, xScale = 1, yScale = 1}) director:changeScene( "question2", "downFlip" ) end end |
Hmm... No response... So did I ask a dumb question here :-)? Anyway, I tried using the timer before changing the scene. Didn't help. It should be something simple. Let the audio finish then change the scene. Still scratching my head....
in case someone is struggling with the same problem... here is how I was able to get it working
1 2 3 4 5 6 7 8 9 10 11 12 | local imageTouched = function ( event ) if event.phase == "began" then transition.to(circle, {time=100, xScale = 1.5, yScale = 1.5}) audio.play(soundYesYouGotIt); elseif event.phase == "ended" then transition.to(circle, {time=100, xScale = 1, yScale = 1}) local function goToNextScene() director:changeScene("question2", "downFlip" ) end timer.performWithDelay ( 1000, goToNextScene ) end end |
That's how I'd do it :)
views:4432 update:2012/2/13 9:11:28