Composer gotoScene bug

--menu.lua composer.gotoScene( "settings", { effect = "slideLeft", time = 400 }  );

--settings.lua function scene:create( event ) composer.gotoScene( "menu", { effect = "slideLeft", time = 400 }  );

Appears black screen and app does not react to any action.

How

Aren’t you creating an infinite loop there, where going to menu goes immediately to settings which goes immediately to menu…

Yeah, bad example.

--menu.lua composer.gotoScene( "settings", { effect = "slideLeft", time = 400 }  );

--settings.lua function scene:create( event ) composer.gotoScene( "someScene", { effect = "slideLeft", time = 400 }  );

Result - black screen.

I have this bug when i press back button (go to prev scene) until the slideLeft not ended - result is black screen again

In the code example you have, the “settings” scene is not allowed to create before you call composer.gotoScene(“someScene”).

If you want to auto advance from your “settings” scene to “someSecne”  you have to wait until the scene gets created first like this:

[lua]

–settings.lua

function scene:show(event)

    if(e.phase == ‘will’) then

    elseif(e.phase == ‘did’) then

        composer.gotoScene( “someScene”, { effect = “slideLeft”, time = 400 }  );

    end

end

[/lua]

But how about back button?

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

And now all is ok. 

P.S. Sory for my bad eng.

Aren’t you creating an infinite loop there, where going to menu goes immediately to settings which goes immediately to menu…

Yeah, bad example.

--menu.lua composer.gotoScene( "settings", { effect = "slideLeft", time = 400 }  );

--settings.lua function scene:create( event ) composer.gotoScene( "someScene", { effect = "slideLeft", time = 400 }  );

Result - black screen.

I have this bug when i press back button (go to prev scene) until the slideLeft not ended - result is black screen again

In the code example you have, the “settings” scene is not allowed to create before you call composer.gotoScene(“someScene”).

If you want to auto advance from your “settings” scene to “someSecne”  you have to wait until the scene gets created first like this:

[lua]

–settings.lua

function scene:show(event)

    if(e.phase == ‘will’) then

    elseif(e.phase == ‘did’) then

        composer.gotoScene( “someScene”, { effect = “slideLeft”, time = 400 }  );

    end

end

[/lua]

But how about back button?

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

And now all is ok. 

P.S. Sory for my bad eng.