我试过这段代码,但我不知道在哪里“把它”:它是在main.lua里面还是在每个level01,level02,等等......?
我尝试插入此代码,但它只能运行一次。我把这段代码放在我的
之前场景:createScene()
function onBackButtonPressedAtMap(e)
if (e.phase == "down" and e.keyName == "back") then
--Here the key was pressed
downPress = true
return true
else
if (e.phase == "up" and e.keyName == "back" and downPress) then
storyboard.returnTo = "start"
Runtime:removeEventListener( "key", onBackButtonPressedAtMap)
return true
end
end
return false
end
Runtime:removeEventListener( "key", onBackButtonPressedAtMap)
答案 0 :(得分:0)
实际上,关键事件代码应该在main.lua中,并且只设置一次。尝试在场景中打开和关闭它有太多问题。
罗布