--Android Keys function BackSelectGame() director:changeScene({scene='scene.main\_menu', arg=nil}, "loader", "scrossfade"); clean\_slate() collectgarbage ("collect") end --handle the Android hardware back and menu buttons function onBackSelectGameKeyEvent( event ) local keyname = event.keyName; if (event.phase == "up" and (event.keyName=="back" or event.keyName=="menu")) then if keyname == "menu" then print("menu function not found") --goToMenuScreen() elseif keyname == "back" then BackSelectGame(); elseif keyname == "search" then print("search function not found") --performSearch(); end end return true; end -- Add the key callback if system.getInfo( "platformName" ) == "Android" then Runtime:addEventListener( "key", onBackSelectGameKeyEvent ) end --cleaner Runtime:removeEventListener("key", onBackSelectGameKeyEvent )
I have a problem with android back key
now I have 4 lua scene and each scene have back function
let say the scene is S1, S2, S3, S4
S4 is the gameplay, if I press back in this scene, it will show the pause option (success)
S3 is the story scene, I made back function to S2 here and I build it
OK S3 back to S2 when I press back button, but when I’m in S4 and press back, it also back to S2
is like the back function on the front scene become global for all scene behind it
each back function already local and it has different name
I don’t know where’s the problem