8

我有这个代码:

local storyboard = require "storyboard"

local options =
{
    effect = "slideLeft",
    time = 800
}

storyboard.gotoScene( "scene1", options )

在同一目录中,我有一个名为“scene1.lua”的文件,但控制台报告此错误:

attempt to concatenate global 'sceneName' (a nil value) in function 'gotoScene'

任何想法,因为发生这种情况?谢谢

4

2 回答 2

15

我找到了解决方案:

在scene1.lua中必须有以下方法和事件监听器:

local storyboard = require( "storyboard" )
local scene = storyboard.newScene()

function scene:createScene( event )

end

function scene:enterScene( event )

end

function scene:exitScene( event )

end

function scene:destroyScene( event )

end

scene:addEventListener( "createScene", scene )
scene:addEventListener( "enterScene", scene )
scene:addEventListener( "exitScene", scene )
scene:addEventListener( "destroyScene", scene )

return scene
于 2012-12-28T07:57:12.760 回答
11

你只是失踪了

return scene

在你的 scene1.lua 文件中。场景功能都是可选的。

于 2013-06-09T06:35:48.793 回答