Hello-
I’m trying to work with scenes, and I’m having a hard time from the start.
I created a test case where I’m creating button graphics that I wish to tap in order to move from scene to scene. I have the following code in my main.lua file- note that I was initially attempting to load in “scene_1” (scene_1.lua) directly from main.lua, but commented it out while attempting to make the tap work. When the commented line is uncommented, and the tap function removed, I get the same error. At any rate, the button tap changes the scene accordingly, but I keep getting a runtime error, which I’ve included below the main block of code.
[blockcode]
local storyboard = require “storyboard”
storyboard.purgeOnSceneChange = true
–storyboard.gotoScene( “scene_1”, “fade”, 400 )
local g = graphics.newGradient(
{ 132, 215, 250 },
{ 200, 200, 200 },
“down” )
local rect = display.newRect( 0, 0, display.contentWidth, display.contentHeight)
rect:setFillColor( g )
rect.x=display.contentWidth/2
rect.y=display.contentHeight/2
local circle1 = display.newCircle(0,0,10)
circle1:setFillColor(128,32,128)
local circle2 = display.newCircle(0,0,10)
circle2:setFillColor(32,15,128)
local circle3 = display.newCircle(0,0,10)
circle3:setFillColor(256,128,128)
local numText1 = display.newText(“1”, 200, 200, native.systemFont, 12)
local numText2= display.newText(“2”, 200, 200, native.systemFont, 12)
local numText3= display.newText(“3”, 200, 200, native.systemFont, 12)
local sceneText1 = display.newText(“Main Screen”, 200, 200, native.systemFont, 24)
local circle_num = {circle1, circle2, circle3}
local text_num = {numText1, numText2, numText3}
for i=1, #circle_num do
circle_num[i].y = display.contentHeight/2
circle_num[i].x = circle_num[i].width +i*circle_num[i].width
text_num[i].x = circle_num[i].x
text_num[i].y = circle_num[i].y
end
function circle1:tap(event)
storyboard.gotoScene(“scene_1” )
end
circle1:addEventListener(“tap”)
[/blockcode]
Here’s the error-
[blockcode]
Runtime error
?:0: attempt to concatenate global ‘sceneName’ (a nil value)
stack traceback:
[C]: ?
?: in function ‘gotoScene’
–filepath is my substitution for the actual filepath
(filepath)/main.lua:66: in function (filepath)/main.lua:65>
?: in function <?:229>
[/blockcode]
Any help or tips in what I’m doing incorrectly would be greatly appreciated! [import]uid: 194953 topic_id: 36268 reply_id: 336268[/import]