使用 Corona SDK: storyboard.gotoScene with effect 函数进行场景切换动画效果。

我在尝试使用 slideLeft 效果在我的菜单 storyboard 和一个叫做 "search" 的 storyboard 之间进行转换。

虽然场景变化,但是没有应用于过渡的效果。或者说根本没有过渡效果。新的场景只是出现了。

我错过了什么吗?

谢谢。

local function goToPage(event)
if (event.phase == "ended") then
    changeButtonIndentation()
    local nextSceneName = "pages." .. event.target.name
    if (storyboard.getCurrentSceneName() ~= nextSceneName) then
        print("From page: " .. storyboard.getCurrentSceneName())
        print("To page: " ..nextSceneName)

        local options =
        {
            effect = "slideLeft",
            time = 1000
        }
        storyboard.gotoScene("pages.search", options)
        currentActivePage = event.target.name
        print(event.target.name)
    end
end
changeButtonIndentation()
end

编辑:显然 options 是起作用的。如果我增加 optionstime 参数,我会发现 search storyboard 上的某些按钮在 1 秒钟内是不可点击的。然而,效果没有起作用。

点赞
用户1502079
用户1502079

尝试先测试确保不是构建错误。

转到帮助 -> 示例项目并打开故事板示例。如果你看到过渡效果,那么问题就在你的代码中。

所以,请尝试这个简化的代码:

local function goToPage(event)
    if (event.phase == "ended") then
        local options =
        {
            effect = "slideLeft",
            time = 1000
        }
        storyboard.gotoScene("pages.search", options)
    end
    return true
end
2013-05-05 21:04:26
用户1870706
用户1870706

如果您是在 enterScene() 函数中创建场景而不是 createScene() 函数中创建场景,则不会有转场的主要原因。

2013-05-05 23:04:58
用户2549544
用户2549544

一种常见的错误是忘记将您的视图元素添加到 self.view 组中。通常,storyboard 模板在 scene:createScene 函数的开头包括 local group = self.view。尝试将您的视图对象插入到该组中。

2013-07-04 11:16:09