Reputation: 99
I am currently trying to figure out how to fade the parent screen by reducing it's alpha when a overlay is shown, only to return the alpha to 1 after the overlay goes away.
I can only seem to make it work with the following
function loreButtonTap:tap(e) transition.to(sceneGroup,{ alpha= .5, time= 400 })
composer.showOverlay("westerosLore", {
effect ="fromTop",
time = 800
})
loreTap = display.newRect(_W,_H,_W*2,_H*2);
display.getCurrentStage():setFocus(loreTap)
loreTap.alpha = 0;
loreTap.isHitTestable = true;
loreTap:addEventListener("tap", loreTap);
function loreTap:tap(e)
transition.to(sceneGroup,{
alpha= 1,
time= 400
})
composer.hideOverlay("slideUp",400);
display.getCurrentStage():setFocus(nil)
end
I am doing all of this from inside of the parent window. The problem is if the player rapidly presses the loreButtonTap (spams it fast), it crashes the game claiming that composer.hideOverlay("slideUp",400);
has become nil
.
Am I supposed to be hiding the overlay in the overlays lua file? Is there a simpler way of doing this?
Upvotes: 0
Views: 353
Reputation: 182
The best way to do this is to draw a black rectangle in your overlay scene and give it an alpha value. This provides a good illusion of faded parent scene.
Upvotes: 1