【问题标题】:how to go to back to a scene in corona sdk after moving to the next scene?移动到下一个场景后如何回到电晕sdk中的一个场景?
【发布时间】:2014-05-25 21:14:55
【问题描述】:

我需要一些帮助, 我在 corona sdk 中制作了一个应用程序,其中包含 4 个场景,main,list,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

}

【问题讨论】:

    标签: sdk lua coronasdk


    【解决方案1】:

    您似乎正在使用“onEvent = handleButtonEvent”函数来处理按钮事件

    您应该改为使用该函数进行转换:

    -- 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
    

    【讨论】:

    • 谢谢,我这样做了,但它就像进入场景列表但没有更改tab2中的内容!我看到tab2了,不知道怎么回事!
    • 在进入列表场景时,您希望 tab2 中的哪些“内容”发生变化?
    • tab2 显示分数,我想在按下按钮时返回列表场景,您可以重新开始!
    • 听起来你没有正确创建场景。我建议您遵循本教程:develephant.net/…,因为它将带您了解 Corona 的故事板!
    • 非常感谢,通过添加storyboard.removeAll() 哈哈!
    猜你喜欢
    • 2017-07-14
    • 1970-01-01
    • 1970-01-01
    • 2015-07-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-22
    • 1970-01-01
    相关资源
    最近更新 更多