Hi all,
I’m new to lua and programming in general. I’m a bit stuck with this particular error message. I don’t really understand what it means and where I have gone wrong.
The error message is:
“Runtime error
?:0: attempt to concatenate global ‘sceneName’ (a nil value)
stack traceback:
[C]: ?
?: in function ‘gotoScene’
/Users/William/Development/Digimals/mainMenu.lua:21: in function ‘onRelease’
?: in function <?:191>
?: in function <?:226>”
If anyone could help me out and let me know what i’m doing wrong that’d be great!
Here is my mainMenu.lua file.
[code]
–
– mainMenu.lua
local storyboard = require( “storyboard” )
local scene = storyboard.newScene()
local widget = require “widget”
local env = require(“env”)
– BEGINNING OF YOUR IMPLEMENTATION
local image
–Touch event listener for new game
local function newGame(event)
storyboard.gotoScene( “mainScene”, “fade”, 400 )
end
local function exitApp(event)
saveDigi()
os.exit()
end
function scene:createScene( event )
local screenGroup = self.view
image = display.newImage( ‘img/normBG.png’)
image.x, image.y = 0,0
image:setReferencePoint(display.CenterReferencePoint)
image.rotation = -90
image.x, image.y = image.height/2,image.width/2
screenGroup:insert( image )
end
– Called immediately after scene has moved onscreen:
function scene:enterScene( event )
print( “1: enterScene event” )
local newGameButton = widget.newButton{
label = “Start”,
onRelease = newGame
}
newGameButton.x = 240
newGameButton.y = 160
local exitGameButton = widget.newButton{
label = “Exit”,
onRelease = exitApp
}
exitGameButton.x = 240
exitGameButton.y = 210
end
– Called when scene is about to move offscreen:
function scene:exitScene( event )
print( “1: exitScene event” )
– remove button
display.remove(newGameButton)
display.remove(exitGameButton)
– remove touch listener for image
–image:removeEventListener( “tap”, image )
end
– Called prior to the removal of scene’s “view” (display group)
function scene:destroyScene( event )
print( “((destroying scene 1’s view))” )
end
– END OF YOUR IMPLEMENTATION
– “createScene” event is dispatched if scene’s view does not exist
scene:addEventListener( “createScene”, scene )
– “enterScene” event is dispatched whenever scene transition has finished
scene:addEventListener( “enterScene”, scene )
– “exitScene” event is dispatched before next scene’s transition begins
scene:addEventListener( “exitScene”, scene )
– “destroyScene” event is dispatched before view is unloaded, which can be
– automatically unloaded in low memory situations, or explicitly via a call to
– storyboard.purgeScene() or storyboard.removeScene().
scene:addEventListener( “destroyScene”, scene )
return scene
[/code] [import]uid: 88841 topic_id: 30760 reply_id: 330760[/import]