Back button while Scene Transition and overlay

Hello, I found out that while I press Native Back button while Scene transition the scene goes out and comes with white Screen(Which is my default background scene). Any ideas for this?

Also I want to close my overlay with back button… Any ideas for this too?

I’m using the latest build and Testing in Win-simulator and Android 5.0

This is my source for back button detect (Based on https://forums.coronalabs.com/topic/56759-back-button-cannot-go-to-previous-scene/))

local function onKeyEvent( event ) local keyName = event.keyName local phase = event.phase local scene = composer.getSceneName( "current" ) local backscene = { ["Info"] = function () goBack ("game", 1) end, ["shop"] = function () goBack ("game", 0) end, ["inApp"] = function () goBack ("shop", 0) end, } if ("back" == keyName and phase == "down") or ("b" == keyName and phase == "down" and system.getInfo("environment") == "simulator") then if (backscene[scene]) then backscene[scene]() return true end end return false end Runtime:addEventListener("key", onKeyEvent)

I do something like this:

local function onKeyEvent( event ) local phase = event.phase local keyName = event.keyName print( event.phase, event.keyName ) if ( "back" == keyName and phase == "up" ) then if ( composer.getCurrentSceneName() == "menu" ) then native.requestExit() else if ( composer.isOverlay ) then composer.hideOverlay() else composer.gotoScene( "menu", { effect="crossFade", time=500 } ) end end return true end return false end

In my case, if I’m in an Overlay, I want to close the overlay. If I’m in a scene other than my menu scene, then I go to the menu scene and on Android if I’m on the menu scene, I request to exit. 

Just a suggestion, instead of testing for the “b” key only when in the sim, you might want to drop the test for the simulator and bind a different key, such as the Escape key, it’s kind of the normal back-out-of-something key. 

Rob

I do something like this:

local function onKeyEvent( event ) local phase = event.phase local keyName = event.keyName print( event.phase, event.keyName ) if ( "back" == keyName and phase == "up" ) then if ( composer.getCurrentSceneName() == "menu" ) then native.requestExit() else if ( composer.isOverlay ) then composer.hideOverlay() else composer.gotoScene( "menu", { effect="crossFade", time=500 } ) end end return true end return false end

In my case, if I’m in an Overlay, I want to close the overlay. If I’m in a scene other than my menu scene, then I go to the menu scene and on Android if I’m on the menu scene, I request to exit. 

Just a suggestion, instead of testing for the “b” key only when in the sim, you might want to drop the test for the simulator and bind a different key, such as the Escape key, it’s kind of the normal back-out-of-something key. 

Rob