Hi. I wrote a code where if a user clicks on help button in menu, it goes to a scene where he can read the help info. When he clicks the back button, its supposed to go back to menu.
This is how I wrote the code in menu.lua for going to help screen. It worked fine.
local function gotoHelp() composer.removeScene( "help" ) composer.gotoScene( "help" ) end helpButton:addEventListener( "tap", gotoHelp )
Now I wrote the code in help.lua in such a way that the user goes back to menu once he presses the back button.
-- Called when a key event has been received local function onKeyEvent( event ) -- If the "back" key was pressed on Android or Windows Phone, make sure it gets back to menu if ( event.keyName == "back" ) then local platformName = system.getInfo( "platformName" ) if ( platformName == "Android" ) or ( platformName == "WinPhone" ) then composer.removeScene( "menu" ) composer.gotoScene( "menu" ) end end return false end Runtime:addEventListener( "key", onKeyEvent )
But this one didn’t work. The game is just getting stopped from being exited but nothing else is happening.
Can anyone please help me?