Composer Overlay always starting

Hello all,

Disclaimer: very new to Corona…

I have a question regarding composer overlays. I’m kind of abusing the overlay function (I think) for a tutorial scene showing. So, I start a scene, and in the scene I have the following:

    if myLevel.showTutorial == true then
        composer.showOverlay( “showtutorial”, {isModal=true, effect=fromTop} )
    end
       
    createLives()
    createProgress()
    createGame()

This does work, but I don’t want the createLives and other functions to start… I want them to wait until the overlay is finished. Is this possible or should I try a different route?

Thanks,

Arne

Hi!

Try to define the time of the overlay transition inside the showOverlay function and then start a timer to run the functions at the bottom only at the end of the overlay.

Like in:

local overlayTime = 500 -- THIS IS TIME IN MILLISECONDS if myLevel.showTutorial == true then local options = { time = overlayTime, --ADDED TIME IN THE OPTIONS isModel = true, effect = fromTop } composer.showOverlay( "showtutorial", options ) -- PASSING THE OPTIONS TABLE CREATED BEFORE end -- DEFINING A FUNCTION THAT CALLS THE THREE FUNCTIONS THAT YOU NEED AFTER THE OVERLAY local actionAfterOverlay = function() createLives() createProgress() createGame() end -- CALLING A TIMER THAT CALLS THE FUNCTION "actionAfterOverlay" after 550ms timer.performWithDelay(overlayTime+50, actionAfertOverlay)

Refer to the API documentation for more info:

https://docs.coronalabs.com/api/library/composer/showOverlay.html (about what parameters can you pass at showOverlay function)

https://docs.coronalabs.com/api/library/timer/performWithDelay.html (about Timers, which you’ll use a lot in pretty dynamic projects)

Hope that helps ^^

Hi Rob,

Thanks for the feedback. Your code looks a lot better than mine :). I did have some code that was having problems (not sure exactly what), but everything is ok.

Thanks again,

Arne

Hi!

Try to define the time of the overlay transition inside the showOverlay function and then start a timer to run the functions at the bottom only at the end of the overlay.

Like in:

local overlayTime = 500 -- THIS IS TIME IN MILLISECONDS if myLevel.showTutorial == true then local options = { time = overlayTime, --ADDED TIME IN THE OPTIONS isModel = true, effect = fromTop } composer.showOverlay( "showtutorial", options ) -- PASSING THE OPTIONS TABLE CREATED BEFORE end -- DEFINING A FUNCTION THAT CALLS THE THREE FUNCTIONS THAT YOU NEED AFTER THE OVERLAY local actionAfterOverlay = function() createLives() createProgress() createGame() end -- CALLING A TIMER THAT CALLS THE FUNCTION "actionAfterOverlay" after 550ms timer.performWithDelay(overlayTime+50, actionAfertOverlay)

Refer to the API documentation for more info:

https://docs.coronalabs.com/api/library/composer/showOverlay.html (about what parameters can you pass at showOverlay function)

https://docs.coronalabs.com/api/library/timer/performWithDelay.html (about Timers, which you’ll use a lot in pretty dynamic projects)

Hope that helps ^^

Hi Rob,

Thanks for the feedback. Your code looks a lot better than mine :). I did have some code that was having problems (not sure exactly what), but everything is ok.

Thanks again,

Arne