移动到下一个场景后如何回到电晕sdk的场景?

时间:2014-05-25 12:43:33

标签: sdk lua corona

我需要一些帮助, 我在corona sdk制作应用程序,其中包含4个场景,主要,列表,tab1,tab2,主要场景通过按钮将您带到列表场景,List将您带到tab1,tab1带您到tab2,我试图做的是让tab2按下按钮返回场景列表,当我按下按钮时没有任何反应!!

local button1 = widget.newButton

    {

    left= 250,
    top= 650,
    defaultFile = "red1.png",
    label = "select chapter",
    font = "Arial",
     fontSize = 34,
    onEvent = handleButtonEvent,
    onPress = function() storyboard.gotoScene( "list" ); end,
    selected = true

}

1 个答案:

答案 0 :(得分:0)

您似乎正在使用函数来处理带有“onEvent = handleButtonEvent”的botton事件

您应该使用该功能进行转换:

-- Function to handle the press of the button
local function handleButtonEvent(event)
    if ( "ended" == event.phase) then
        storyboard.gotoScene("list")
    end
end

-- Creation of the button
local button1 = widget.newButton
{
    -- All your variables here
    onEvent = handleButtonEvent,    
}

你甚至可能正在寻找这样的东西;此功能将使用户返回上一个场景。

-- Function to handle the press of the button
local function handleButtonEvent(event)
    if ( "ended" == event.phase) then
        storyboard.gotoScene(storyboard.getPrevious())
    end
end
相关问题