I’ve tried every combination I could think of with Android back button code to fix this. NOTHING has worked. Example: If I’m on lvl1.lua and change to lvl2.lua with Director and press the Android “back” button RIGHT when the screen switches to the new level it fires both screens backbutton events and double loads everything. I am cancelling the listener when I leave one page to go to the next. Any ideas?
[lua] local function onKeyEvent( event )
local returnValue = true
if (event.phase == “down” and (event.keyName==“back”)) then
director:changeScene(“lvl1”)
return true --Must return true inside “if” statement
end
if (event.phase == “up” and (event.keyName==“back”)) then
–handles the “up” phase on the Nook “N” button
return true
end
if (event.phase == “down” and (event.keyName==“volumeUp”)) then
returnValue = false – Keep normal function
end
if (event.phase == “down” and (event.keyName==“volumeDown”)) then
returnValue = false – Keep normal function
end
return returnValue
end
Runtime:addEventListener( “key”, onKeyEvent )[/lua] [import]uid: 46082 topic_id: 34750 reply_id: 334750[/import]