我的游戏中有一个后退按钮。它有一个名为btnTap的点击事件。点击它会给出一个警告,其中给用户两个选项,转到“luduMenu”场景或继续播放。但是它不起作用,当我点击是时,场景仍然保持不变。这是我试过的代码。
local onComplete = function ( event )
if "clicked" == event.action then
local i = event.index
if 1 == i then
-- Do nothing; dialog will simply dismiss
system.setIdleTimer( true )
storyboard.gotoScene ( "luduMenu" )
elseif 2 == i then
-- Open URL if "Learn More" (the 2nd button) was clicked
end
end
end
-- local forward references should go here --
local function btnTap(event)
local alert1 = native.showAlert( "Go Back", "Are you sure?", { "Yes", "No" }, onComplete )
return true
end
答案 0 :(得分:0)
我通过删除行
解决了这个问题storyboard.purgeScene("onevsone")
来自场景的exitscene事件并安排如下代码
local function btnTap(event)
local function onAlertComplete(event)
if "clicked" == event.action then
local i = event.index
if i == 1 then
storyboard.gotoScene("luduMenu")
end
end
end
native.showAlert( "End Game?", "Are you sure you want to exit this game?", { "Yes", "No" }, onAlertComplete )
return true
end