local function onKeyEvent(event) local phase = event.phase local keyName = event.keyName if ("back" == keyName and phase == "down") or ("b" == keyName and phase == "down" and system.getInfo("environment") == "simulator") then local currSceneName = composer.getSceneName( "current" ) local currScene = composer.getScene( currSceneName ) if ( composer.isOverlay ) then composer.hideOverlay( "fade", 200 ) composer.isOverlay = false elseif currScene.returnTo ~= nil then composer.gotoScene( currScene.returnTo, { effect = "slideRight", time = 400 } ) return true end return false end Runtime:addEventListener( "key", onKeyEvent )
When i pressing back button untill animation gotoScene not ended - black screen
I got this solution:
settings.lua
function scene:show( event ) local group = self.view if ( event.phase == "will" ) then scene.loaded = false elseif ( event.phase == "did" ) then scene.loaded = true end end
main.lua
if ( composer.isOverlay ) then composer.hideOverlay( "fade", 200 ) composer.isOverlay = false elseif currScene.returnTo ~= nil and currScene.loaded then composer.gotoScene( currScene.returnTo, { effect = "slideRight", time = 400 } ) return true end
local function onKeyEvent(event) local phase = event.phase local keyName = event.keyName if ("back" == keyName and phase == "down") or ("b" == keyName and phase == "down" and system.getInfo("environment") == "simulator") then local currSceneName = composer.getSceneName( "current" ) local currScene = composer.getScene( currSceneName ) if ( composer.isOverlay ) then composer.hideOverlay( "fade", 200 ) composer.isOverlay = false elseif currScene.returnTo ~= nil then composer.gotoScene( currScene.returnTo, { effect = "slideRight", time = 400 } ) return true end return false end Runtime:addEventListener( "key", onKeyEvent )
When i pressing back button untill animation gotoScene not ended - black screen
I got this solution:
settings.lua
function scene:show( event ) local group = self.view if ( event.phase == "will" ) then scene.loaded = false elseif ( event.phase == "did" ) then scene.loaded = true end end
main.lua
if ( composer.isOverlay ) then composer.hideOverlay( "fade", 200 ) composer.isOverlay = false elseif currScene.returnTo ~= nil and currScene.loaded then composer.gotoScene( currScene.returnTo, { effect = "slideRight", time = 400 } ) return true end