Lua - code problem

Hello everyone,

I would like to create my first game  with tutorial - click

Unfortunately, I have some errors, but I don’t know how to fix that. Can you look at my code? Here is one of files: 

display.setStatusBar(display.HiddenStatusBar) local storyboard = require "storyboard" storyboard.gotoScene("game")

here is the second:

-- requires local physics = require "physics" physics.start() local storyboard = require "storyboard" local scene = storyboard.newScene() -- background function scene:createScene(event) local screenGroup = self.view local background = display.newImage("bg.png") city1 = display.newImage("city1.png") city1.x = 0 city1.y = 120 city1.speed = 1 city2 = display.newImage("city1.png") city2.x = 480 city2.y = 120 city2.speed = 1 city3 = display.newImage("city2.png") city3.x = 0 city3.y = 420 city3.speed = 2 city4 = display.newImage("city2.png") city4.x = 480 city4.y = 420 city4.speed = 2 jet = display.newImage("redJet.png") jet.x = 100 jet.y = 100 physics.addBody(jet, "dynamic", {density=.1, bounce=0.1, friction=.2, radius=12}) end function scrollCity(self, event) if self.x \< -477 then self.x = 480 else self.x = self.x - self.speed end end function activateJets(self, event) self:applyForce(0, -1.5, self.x, self.y) end function touchScreen(event) -- print("touch") if event.phase == "began" then jet.enterFrame = activateJets Runtime:addEventListener("enterFrame", jet) end if event.phase == "ended" then Runtime:removeEventListener("enterFrame", jet) end end function scene:enterScene(event) Runtime:addEventListener("touch", touchScreen) city1.enterFrame = scrollCity Runtime:addEventListener("enterFrame", city1) city2.enterFrame = scrollCity Runtime:addEventListener("enterFrame", city2) city3.enterFrame = scrollCity Runtime:addEventListener("enterFrame", city3) city4.enterFrame = scrollCity Runtime:addEventListener("enterFrame", city4) 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

Error’s screen:

  5f4qj7.jpg

My code is the same like code in the tutorial. What’s wrong? What should I do? :frowning:

Greetings,

Angela

You are watching an older tutorial. We no longer support storyboard, but instead have Composer (i.e. storyboard 2.0). If you want to use storyboard you can, you just have to download the code and add it to your project.  Go to:

https://github.com/coronalabs/framework-storyboard-legacy

Download the code as a .zip file. Unzip it and copy “storyboard.lua” into the same folder as your main.lua and you should be all set.

I would recommend at some point, you look through our Documentation:

https://docs.coronalabs.com/guide/system/composer/index.html

https://docs.coronalabs.com/api/library/composer/index.html

And perhaps after you get your tutorial working, you can convert it over to Composer.

Rob

Hi Angela,

The “storyboard” library was deprecated about 2 years ago, in favor of Composer, the official Corona scene management library. While you can still manually include Storyboard in a project as noted in the following tutorial roundup, we highly recommend that you convert legacy Storyboard-enabled projects to Composer. The process is relatively easy, because the two libraries share many core design aspects, and by converting to Composer, you ensure the project is future-proof.

This should get you started:

https://coronalabs.com/blog/2015/08/11/tutorial-treasury-composer/

Best regards,

Brent

Ok, I know what to do now. Thank you for help! :slight_smile:

You are watching an older tutorial. We no longer support storyboard, but instead have Composer (i.e. storyboard 2.0). If you want to use storyboard you can, you just have to download the code and add it to your project.  Go to:

https://github.com/coronalabs/framework-storyboard-legacy

Download the code as a .zip file. Unzip it and copy “storyboard.lua” into the same folder as your main.lua and you should be all set.

I would recommend at some point, you look through our Documentation:

https://docs.coronalabs.com/guide/system/composer/index.html

https://docs.coronalabs.com/api/library/composer/index.html

And perhaps after you get your tutorial working, you can convert it over to Composer.

Rob

Hi Angela,

The “storyboard” library was deprecated about 2 years ago, in favor of Composer, the official Corona scene management library. While you can still manually include Storyboard in a project as noted in the following tutorial roundup, we highly recommend that you convert legacy Storyboard-enabled projects to Composer. The process is relatively easy, because the two libraries share many core design aspects, and by converting to Composer, you ensure the project is future-proof.

This should get you started:

https://coronalabs.com/blog/2015/08/11/tutorial-treasury-composer/

Best regards,

Brent

Ok, I know what to do now. Thank you for help! :slight_smile: