I cannot seem to get this scene working properly

Hello to all, I’m following this tutorial here by Mark Falkland, yes i know the tutorial is almost 2 years old but everything worked for me until i started to set up storyboard. I believe i did everything correctly and i even started this project from scratch over twice just to make sure i did everything properly. I have even looked at the sample code of storyboard that comes with the installation of Corona SDK in the “Interface” folder but that didn’t work either… So what am i doing wrong? 

Here is the Specs…

*Mac OS X 10.9.2

*Newest version of Corona SDK

              Here is pictures of the error when i try to launch

              Here is the code i have for the "main.lua"

              And here is the code to my "game.lua"

              This picture is continued from line 71

If there is anymore information that i left out or needed please let me know and i will provide that. :slight_smile:

The error you have means you have some line of code that starts a block and you are missing end to end the block.  The block could be a “function”, “if”, “while”, “for” or “repeat” line.  For every one of those, you need to have a matching end.  Without seeing the whole code, its going to be impossible to spot it.

What you can do is in Sublime Text, do a CTRL-A (Windows) CMD-A (Mac) to do a select all and then CTRL-C (Windows) or CMD-C (Mac) to copy the text.

Next, here in the forum post window, type in:

[code]    (take out the space, I have to put it in to keep the forums from handling it:

then press CTRL-V (Windows) or CMD-V (Mac) to paste the text in, then close the code with a:

[/code]  (again take the space out)

Rob

-- main.lua display.setStatusBar( display.HiddenStatusBar ) local storyboard = require "storyboard" storyboard.gotoScene ("game") -- game.lua -- Requires Physics -- local physics = require "physics" physics.start() local storyboard = require ( "storyboard" ) local scene = storyboard.newScene() -- Background -- function scene:createScene(event) local screenGroup = self.view storyboard.gotoScene( "game" ) return true end end local background = display.newImage("newbg.png") -- City 1 -- local city1 = display.newImage("City1.png") city1:setReferencePoint(display.BottomLeftReferencePoint) city1.x = 0 city1.y = 320 local scrollcity1 = display.newImage("City1.png") scrollcity1:setReferencePoint(display.BottomLeftReferencePoint) scrollcity1.x = 480 scrollcity1.y = 320 city1.speed = 1 -- City 2 -- local city2 = display.newImage("City2.png") city2:setReferencePoint(display.BottomLeftReferencePoint) city2.x = 0 city2.y = 320 local scrollcity2 = display.newImage("City2.png") scrollcity2:setReferencePoint(display.BottomLeftReferencePoint) scrollcity2.x = 480 scrollcity2.y = 320 city2.speed = 2 -- City 3 -- local city3 = display.newImage("City3.png") city3:setReferencePoint(display.BottomLeftReferencePoint) city3.x = 480 city3.y = 320 local scrollcity3 = display.newImage("City3.png") scrollcity3:setReferencePoint(display.BottomLeftReferencePoint) scrollcity3.x = 480 scrollcity3.y = 320 city3.speed = 3 end function scene:enterScene(event) city1.enterFrame = scrollCity Runtime:addEventListener("enterFrame", city1) city2.enterFrame = scrollCity Runtime:addEventListener("enterFrame", city2) city3.enterFrame = scrollCity Runtime:addEventListener("enterFrame", city3) Runtime:addEventListener("touch", touchScreen) -- First Plane -- local FirstPlane = display.newImage("FirstPlane.png") FirstPlane.x = 80 FirstPlane.y = 50 physics.addBody(FirstPlane, "dynamic" , {density=.1, bounce=0.2, friction=.2, radius=12}) end function scrollCity(self, event) if self.x \< -500 then self.x = 480 else self.x =self.x - self.speed end end function activateFirstPlane(self,event) self:applyForce(0, -1.5, self.x, self.y) end function touchScreen(event) -- print("touch") if event.phase == "began" then FirstPlane.enterFrame = activateFirstPlane Runtime:addEventListener("enterFrame", FirstPlane) end if event.phase == "ended" then Runtime:removeEventListener("enterFrame", FirstPlane) 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 end

That’s all the code, let me know if there is anything else needed. 

I would also read the chapter in the lua guide on Tables and Objects, particularly the bit on arrays. You have in your design three pretty much identical ‘cities’

Usually when you have lots of the same thing, or very similar things, you should be using arrays or data structures. It makes your code shorter and more readable.

Last point - you are adding Runtime Listeners for enterFrame to your cities , it is usually a good idea to remove them see http://coronalabs.com/blog/2012/09/05/faq-wednesday-removing-event-listeners-and-display-objects/

The error you have means you have some line of code that starts a block and you are missing end to end the block.  The block could be a “function”, “if”, “while”, “for” or “repeat” line.  For every one of those, you need to have a matching end.  Without seeing the whole code, its going to be impossible to spot it.

What you can do is in Sublime Text, do a CTRL-A (Windows) CMD-A (Mac) to do a select all and then CTRL-C (Windows) or CMD-C (Mac) to copy the text.

Next, here in the forum post window, type in:

[code]    (take out the space, I have to put it in to keep the forums from handling it:

then press CTRL-V (Windows) or CMD-V (Mac) to paste the text in, then close the code with a:

[/code]  (again take the space out)

Rob

-- main.lua display.setStatusBar( display.HiddenStatusBar ) local storyboard = require "storyboard" storyboard.gotoScene ("game") -- game.lua -- Requires Physics -- local physics = require "physics" physics.start() local storyboard = require ( "storyboard" ) local scene = storyboard.newScene() -- Background -- function scene:createScene(event) local screenGroup = self.view storyboard.gotoScene( "game" ) return true end end local background = display.newImage("newbg.png") -- City 1 -- local city1 = display.newImage("City1.png") city1:setReferencePoint(display.BottomLeftReferencePoint) city1.x = 0 city1.y = 320 local scrollcity1 = display.newImage("City1.png") scrollcity1:setReferencePoint(display.BottomLeftReferencePoint) scrollcity1.x = 480 scrollcity1.y = 320 city1.speed = 1 -- City 2 -- local city2 = display.newImage("City2.png") city2:setReferencePoint(display.BottomLeftReferencePoint) city2.x = 0 city2.y = 320 local scrollcity2 = display.newImage("City2.png") scrollcity2:setReferencePoint(display.BottomLeftReferencePoint) scrollcity2.x = 480 scrollcity2.y = 320 city2.speed = 2 -- City 3 -- local city3 = display.newImage("City3.png") city3:setReferencePoint(display.BottomLeftReferencePoint) city3.x = 480 city3.y = 320 local scrollcity3 = display.newImage("City3.png") scrollcity3:setReferencePoint(display.BottomLeftReferencePoint) scrollcity3.x = 480 scrollcity3.y = 320 city3.speed = 3 end function scene:enterScene(event) city1.enterFrame = scrollCity Runtime:addEventListener("enterFrame", city1) city2.enterFrame = scrollCity Runtime:addEventListener("enterFrame", city2) city3.enterFrame = scrollCity Runtime:addEventListener("enterFrame", city3) Runtime:addEventListener("touch", touchScreen) -- First Plane -- local FirstPlane = display.newImage("FirstPlane.png") FirstPlane.x = 80 FirstPlane.y = 50 physics.addBody(FirstPlane, "dynamic" , {density=.1, bounce=0.2, friction=.2, radius=12}) end function scrollCity(self, event) if self.x \< -500 then self.x = 480 else self.x =self.x - self.speed end end function activateFirstPlane(self,event) self:applyForce(0, -1.5, self.x, self.y) end function touchScreen(event) -- print("touch") if event.phase == "began" then FirstPlane.enterFrame = activateFirstPlane Runtime:addEventListener("enterFrame", FirstPlane) end if event.phase == "ended" then Runtime:removeEventListener("enterFrame", FirstPlane) 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 end

That’s all the code, let me know if there is anything else needed. 

I would also read the chapter in the lua guide on Tables and Objects, particularly the bit on arrays. You have in your design three pretty much identical ‘cities’

Usually when you have lots of the same thing, or very similar things, you should be using arrays or data structures. It makes your code shorter and more readable.

Last point - you are adding Runtime Listeners for enterFrame to your cities , it is usually a good idea to remove them see http://coronalabs.com/blog/2012/09/05/faq-wednesday-removing-event-listeners-and-display-objects/