Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Corona: Attempt to concatenate global 'sceneName'

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

like image 919
Xose Avatar asked Dec 27 '12 15:12

Xose


2 Answers

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
like image 102
Xose Avatar answered Nov 10 '22 18:11

Xose


You were just missing

return scene

in your scene1.lua file. Scene functions are all optional.

like image 30
john_c Avatar answered Nov 10 '22 17:11

john_c