当前位置 : 主页 > 网络编程 > lua >

lua – Corona:尝试连接全局’sceneName’

来源:互联网 收集:自由互联 发布时间:2021-06-23
我有这个代码: local storyboard = require "storyboard"local options ={ effect = "slideLeft", time = 800}storyboard.gotoScene( "scene1", options ) 在同一目录中,我有一个名为“scene1.lua”的文件,但是控制台报告此错
我有这个代码:

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'

任何想法,因为发生这个?谢谢

我找到了解决方案:

在scene1.lua中必须有以下方法和eventListeners:

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
网友评论