I am excuting composer.showOverlay() within other composer.showOverlay() but the composer.hideOverlay() does not working properly.
In the below code I am expecting :
- The circle will not be displayed
- After touching the rectangle it will be disappeared
BUT INSTEAD I am getting the wrong result:
- The circle is displayed
- After touching the rectangle the circle is disappeared (and the box remain)
The code involves 3 files as follow (due to the size of the code I will put only the relevant code).
The collisionEvent.lua contains :
local function explosionSpriteListener(inEvent) --This is event is fired from collision if inEvent.phase == "ended" then composer.showOverlay("extraLife", {isModal = false} ) end end
The extraLife.lua contains:
function scene:show( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then elseif ( phase == "did" ) then local c=display.newCircle( sceneGroup, 200, 450,25 ) composer.hideOverlay() --expecting that the circle will be removed but it doesn't composer.showOverlay("PauseMenu", { isModal = false , params = {accessFrom = extraLife"} }) end end
The PauseMenu.lua contains:
function scene:show( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then elseif ( phase == "did" ) then local function removeOverlay(event) print("The Box should be removed - BUT it doesn't") composer.hideOverlay() end local b=display.newRect( sceneGroup, 100, 300, 200, 200 ) b:addEventListener( "touch", removeOverlay ) end end