event.phase

Type String
Event hide
Revision 2017.3060
Keywords composer, scene, hide, event

Overview

For the hide event, event.phase is the string value of "will" when the scene is on screen (but is about to go off screen). In contrast, event.phase will be the string value of "did" immediately after the scene goes off screen. If a scene transition effect is specified for the new scene or the overlay, the "will" phase is dispatched before the effect begins execution and the "did" phase is dispatched after the effect is finished.

Example

local composer = require( "composer" )
local scene = composer.newScene()

function scene:hide( event )

    local phase = event.phase

    if ( phase == "will" ) then
        -- Called when the scene is on screen (but is about to go off screen).
        -- Insert code here to "pause" the scene.
        -- Example: stop timers, stop animation, unload audio, etc.
    elseif ( phase == "did" ) then
        -- Called immediately after scene goes off screen.
    end
end
scene:addEventListener( "hide" )