Type String
Event show
Revision 2017.3145
Keywords composer, scene, show, event


For the show event, event.phase is the string value of "will" if the scene is about to become active, or "did" after the scene comes on screen. It can be accessed from the event listener for show events that are dispatched to scene objects. If a scene transition effect is specified, the "will" phase is dispatched before the scene effect begins execution. In contrast, the "did" phase is not dispatched until after the effect is finished.


-- From "scene1.lua"
composer.gotoScene( "scene2", { effect="fade", time=800 } )

-- In "scene2.lua"
local composer = require( "composer" )
local scene = composer.newScene()

function scene:show( event )

    local phase = event.phase

    if ( phase == "will" ) then
        -- Called when the scene is still off screen (but is about to come on screen).
    elseif ( phase == "did" ) then
        -- Called when the scene is now on screen.
        -- Insert code here to make the scene come alive.
        -- Example: start timers, begin animation, play audio, etc.

scene:addEventListener( "show" )