I used storyboard overlays extensively in the past. I am not grokking composer overlays.
composer.showOverlay() has been working great, as expected.
composer.hideOverlay() does nothing for me.
My basic conception looks like this
----------------------------------------------------------------------------------------- -- -- any-scene.lua -- ----------------------------------------------------------------------------------------- local composer = require( "composer" ) local scene = composer.newScene() -- "scene:create()" function scene:create( event ) local sceneGroup = self.view local pad = display.newRect(sceneGroup, display.contentCenterX, display.contentCenterY, 200, 100 ) pad.fill = {.2,.2,.2} local function overlayUp(event) local phase = event.phase if phase == "ended" then composer.showOverlay( "any-overlay", { effect = "fromBottom", time = 500, isModal = true, } ) end end pad:addEventListener( "touch", overlayUp ) end -- "scene:show()" function scene:show( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then elseif ( phase == "did" ) then end end -- "scene:hide()" function scene:hide( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then elseif ( phase == "did" ) then end end -- "scene:destroy()" function scene:destroy( event ) local sceneGroup = self.view end -- ------------------------------------------------------------------------------- -- Listener setup scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) return scene
------------------------------------------------------------------------------ -- -- any-overlay.lua -- ------------------------------------------------------------------------------ local composer = require( "composer" ) local scene = composer.newScene() -- "scene:create()" function scene:create( event ) local sceneGroup = self.view local awayPad = display.newRect(sceneGroup, display.contentCenterX, display.contentCenterY, 400, 300 ) awayPad.fill = {0,0,0,0.5} local overlayDown = function (event) local phase = event.phase if phase == "ended" then composer.hideOverlay() end end awayPad:addEventListener( "touch", overlayDown) end -- "scene:show()" function scene:show( event ) local sceneGroup = self.view local phase = event.phase local parent = event.parent if ( phase == "will" ) then elseif ( phase == "did" ) then end end -- "scene:hide()" function scene:hide( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then elseif ( phase == "did" ) then end end -- "scene:destroy()" function scene:destroy( event ) local sceneGroup = self.view end -- Listener setup scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) return scene