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

前端之家收集整理的这篇文章主要介绍了lua – Corona:尝试连接全局’sceneName’前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有这个代码
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

猜你在找的Lua相关文章