To change scenes using the hardware back button for Android, I’m using this code:
local function onKeyEvent( event ) local returnValue = true local phase = event.phase local keyName = event.keyName if "back" == keyName then display.remove(Objects);Objects = nil director:changeScene("scene") end return returnValue end
And no matter what scene it’s in, it always goes to “Menu”. The sequence in my app goes like this:
Menu -> Scene1 -> Scene2 -> Scene3
Scene1 goes back to Menu, Scene2 should go back to Scene1 and Scene3 shold go back to Scene2 … but Scene2 and 3 always go back to the Menu regardless of what "director:changeScene() is and regardless if the Runtime listener is removed. Maybe I’m not removing them properly, but I’ve tried almost every trick in the book. On some scenes, the app just crashes. I have the latest build. Can anyone help?