Basic Storyboard Question

Hey guys,

I’ve been using corona for a while and the app I’m currently making was built poorly with everything in the same file. So yesterday I decided to move everything around and set it up with Storyboard.

That’s when I got lost. So I went back to the basics and tried to make a very basic scene but upon doing so I couldn’t get it to work. I cant get my display object to show up? What am I doing wrong???

local storyboard = require "storyboard"  
local scene = storyboard.newScene()  
  
local box1  
  
function scene:createScene( event )  
 local group = self.view  
  
 box1 = display.newRect( 100, 100, 100, 100 )  
 group:insert(box1)  
end  
  
function scene:enterScene( event )  
 box1.isVisible = true  
end  
  
scene:addEventListener( "enterScene", scene )  
scene:addEventListener( "createScene", scene )  
  
return scene  
  

Thanks in advance. I read so much about storyboard but I guess I still don’t quite understand how to use it. [import]uid: 28246 topic_id: 33715 reply_id: 333715[/import]

I imagine you put that code into your main.lua which is the problem. You have a scene created there but you are never switching to it so your enter/create events don’t get called.

Instead of putting that code in your main.lua, move it to another file called test.lua and change your main.lua code to be as below:

[lua]local storyboard = require(“storyboard”)
storyboard.gotoScene(“test”)[/lua]

It should switch to the scene you created and your box will show up. [import]uid: 147305 topic_id: 33715 reply_id: 134053[/import]

Okay that works. I guess I don’t quite understand how storyboard is supposed to be used then. What do you put in a main.lua file then if it just get’s forwarded to the first scene in a different file? [import]uid: 28246 topic_id: 33715 reply_id: 134093[/import]

I use it pretty much as my startup file with the storyboard.gotoScene call at the very end. If I needed to setup a database or set any global variables like like ‘soundOn’ or whatever. If you start a new project in Corona and choose App as the template you can see that they defined a tab bar in the main.lua which switches between scenes. [import]uid: 147305 topic_id: 33715 reply_id: 134094[/import]

Alright that makes sense. Thanks! [import]uid: 28246 topic_id: 33715 reply_id: 134096[/import]

I imagine you put that code into your main.lua which is the problem. You have a scene created there but you are never switching to it so your enter/create events don’t get called.

Instead of putting that code in your main.lua, move it to another file called test.lua and change your main.lua code to be as below:

[lua]local storyboard = require(“storyboard”)
storyboard.gotoScene(“test”)[/lua]

It should switch to the scene you created and your box will show up. [import]uid: 147305 topic_id: 33715 reply_id: 134053[/import]

Okay that works. I guess I don’t quite understand how storyboard is supposed to be used then. What do you put in a main.lua file then if it just get’s forwarded to the first scene in a different file? [import]uid: 28246 topic_id: 33715 reply_id: 134093[/import]

I use it pretty much as my startup file with the storyboard.gotoScene call at the very end. If I needed to setup a database or set any global variables like like ‘soundOn’ or whatever. If you start a new project in Corona and choose App as the template you can see that they defined a tab bar in the main.lua which switches between scenes. [import]uid: 147305 topic_id: 33715 reply_id: 134094[/import]

Alright that makes sense. Thanks! [import]uid: 28246 topic_id: 33715 reply_id: 134096[/import]