I have three scenes (scene2, scene3, scene4). After I had run all three screen, i only manage to return to “screen3” from “screen4” after that i can not return to screen “screen2” from “screen3”.
If I use “composer: gotoScene” in an event other than the back button , it works
[lua]
-----------------main.lua
local composer = require( “composer” )
composer.gotoScene(“scene2”)
-----------------scene2.lua
function scene:create( event )
local sceneGroup = self.view
local textScene2 = display.newText(“scene2”, 50, 50, native.systemFont, 12)
sceneGroup:insert(textScene2)
textScene2:addEventListener(“tap”, nextScene)
end
function nextScene(event)
composer.gotoScene(“scene3”)
end
function scene:show( event )
local textScene2 = display.newText(“scene2”, 50, 100, native.systemFont, 12)
local sceneGroup = self.view
sceneGroup:insert(textScene2)
end
…
-----------------scene3.lua
function scene:create( event )
sceneGroup = self.view
goToScene4 = display.newText(“scene3”, 50, 50, native.systemFont, 12)
goToScene4:addEventListener(“tap”, onTapNext)
goToScene2 = display.newText(“goScene2”, 50, 100, native.systemFont, 12)
goToScene2:addEventListener(“tap”, onTapBack)—WORK
sceneGroup:insert(goToScene2)
sceneGroup:insert(goToScene4)
Runtime:addEventListener(“key”, onKeyEvent)—NOT WORK
end
function onKeyEvent(event)—NOT WORK
if ( event.keyName == “back” and event.phase == “up”) then
composer.gotoScene(“scene2”)
return true
end
return false
end
function onTapNext(event)
composer.gotoScene(“scene4”)
end
function onTapBack(event)—WORK
composer.gotoScene(“scene2”)
end
…
-----------------scene4.lua
function scene:create( event )
sceneGroup = self.view
goToScene3 = display.newText(“scene4”, 50, 50, native.systemFont, 12)
sceneGroup:insert(goToScene3)
Runtime:addEventListener(“key”, onKeyEvent)
end
function onKeyEvent(event)
if ( event.keyName == “back” and event.phase == “up”) then
composer.gotoScene(“scene3”)
return true
end
return false
end
[/lua]