FusePowered

delaying changeScene

3 replies [Last post]
saidul.islam
User offline. Last seen 1 year 23 weeks ago. Offline
Joined: 20 Mar 2011

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

Replies

saidul.islam
User offline. Last seen 1 year 23 weeks ago. Offline
Joined: 20 Mar 2011

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....

saidul.islam
User offline. Last seen 1 year 23 weeks ago. Offline
Joined: 20 Mar 2011

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

it's kind of funny but it works :-)

WauloK
User offline. Last seen 2 years 10 weeks ago. Offline
Joined: 21 Oct 2010

That's how I'd do it :)

Viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.