I’m having problems with the Android Back key. I’ve tried almost everything I can think of, I thought I found some ways that worked, but I apparently not. No matter what scene I’m in, the back button will only bring me back to the main menu, rather than the previous scene like it should.
I’ve looked at the API, I’ve looked at http://www.coronalabs.com/blog/2013/03/26/androidizing-your-mobile-app/ … and the “Example Code” does nothing but show how worthless it can be.
A map of my app…
Menu > Menu2 > Tutorials > Tutorial1
Tutorials should go back to Menu2 , Tutorial1 should go back to Tutorials , but both go back to Menu.
I have this function below in all of my scenes with their respective “changeScene”'s to go back to the previous screen; but as I mentioned, ALL bring me back to the main menu.
local function moveBack() Runtime:removeEventListener("key", onKeyEvent) display.remove(allObjects);allObjects=nil director:changeScene("previousScene", "crossfade") end local function onKeyEvent( event ) local returnValue = true if (event.phase=="up" and event.keyName=="back") then timer.performWithDelay(100,moveBack,1) end return returnValue end Runtime:addEventListener( "key", onKeyEvent )
This is making me pull my hair out, I’ve been working on it for a good 2 months now and it’s the only thing preventing me from publishing my app.