Sounds like an error somewhere in your code. I’m able to switch between all my scenes without any problems.
To exit my game from the main menu I handle the back button, drop down a menu with “Exit Game?” with yes or no buttons, if yes is pushed then exit game with os.exit().
I’m using an older version of Director with its cleanup function. Director Beta 1.3 or earlier should work with the code below. Here’s a complete scene of how the back button can be handled in a director scene. I hope the code is not too long for this post :o|
[code]module(…, package.seeall)
– GROUPS
local localGroup = display.newGroup()
– BACK BUTTON FLAG
local backButtonPushed = false
– LISTENERS
local function animate(event)
if backButtonPushed == true then
backButtonPushed = false
os.exit()
– or
–director:changeScene(“menu”)
end
end
local function onKeyEvent( event )
local phase = event.phase
local keyName = event.keyName
if phase == “up” and (keyName == “back”) then
backButtonPushed = true
end
return true
end
– INIT VARS
local function initVars ()
– Listeners
Runtime:addEventListener( “key”, onKeyEvent )
Runtime:addEventListener( “enterFrame”, animate )
end
– CLEAN
function clean ( event )
Runtime:removeEventListener( “key”, onKeyEvent )
Runtime:removeEventListener( “enterFrame”, animate )
backButtonPushed = nil
end
– NEW
function new()
– Initiate variables
initVars()
– MUST return a display.newGroup()
return localGroup
end
[/code]
[import]uid: 38820 topic_id: 12404 reply_id: 45416[/import]