hideOverly() not working in showOvelray within other ShowOverlay

I am excuting  composer.showOverlay() within other composer.showOverlay() but the composer.hideOverlay() does not working properly.

In the below code I am expecting  :

  1. The circle will not be displayed
  2. After touching  the rectangle it will be disappeared

BUT INSTEAD I am getting the wrong result:

  1. The circle is displayed
  2. 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

Yeah, I don’t think that’s legal.  You need to wait one frame before closing the overlay.

Try this:

timer.performWithDelay( 1, function() composer.hideOverlay() composer.showOverlay( "overlay2", { isModal = false , params = { accessFrom = "scene1" } } ) end )

I think composer needs one frame to finish the accounting and determine which objects is managing.  If you immediately hide/close the overlay, that step gets goofed up.  (Just a guess though.)

Can you elaborate on why you want to do this, or is this an experiment to look into another issue?

You can only have one active overlay at a time.

Yeah, I don’t think that’s legal.  You need to wait one frame before closing the overlay.

Try this:

timer.performWithDelay( 1, function() composer.hideOverlay() composer.showOverlay( "overlay2", { isModal = false , params = { accessFrom = "scene1" } } ) end )

I think composer needs one frame to finish the accounting and determine which objects is managing.  If you immediately hide/close the overlay, that step gets goofed up.  (Just a guess though.)

Can you elaborate on why you want to do this, or is this an experiment to look into another issue?

You can only have one active overlay at a time.