Hi all,
I’m trying to figure out a way of navigating back to main menu using the android Back/Return key.
Currently I’m using director.lua library to switch from one “scene” (menu) to other scenes “other menus” and I’d like to knwo how I can use
Runtime:addEventListener(“key”,onKeyEvent) to properly handle navigation.
I guess I’m not fully grasping what’s going on, because ussualy the back key will force exit the application.
Typically, you’d do:
local function onBackButtonPressed(e)
if (e.phase == "down" and e.keyName == "back") then
director:changeScene("menu","crossfade")
end
return true
end
Runtime:addEventListener( "key", onBackButtonPressed )
However the back button creates 2 events: down and up, and I’m not sure how and when I should remove the event listener, inside which scene, etc.
has anyone got an ideea on how a proper implementation of back button navigation would be done?
Thank you. [import]uid: 117906 topic_id: 21320 reply_id: 321320[/import]