Corona: Attempt to concatenate global 'sceneName'

Xose picture Xose · Dec 27, 2012 · Viewed 8.6k times · Source

I have this code:

local storyboard = require "storyboard"

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

storyboard.gotoScene( "scene1", options )

In the same directory I have a file named "scene1.lua", but console reports this error:

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

Any idea because happen this? Thanks

Answer

Xose picture Xose · Dec 28, 2012

I found the solution:

In scene1.lua must be have the following methods and 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