Composer: naming scenes?

Storyboard names a scene when creating a new scene. Composer seems to do the same, but the documentation says otherwise. It says that the passed string refers to a Composer GUI file, not the name of the scene.

How do we properly name a scene with Composer?

composer.newScene( ccscene )

ccscene (optional)

String. Reference to a .ccscene file created and updated by the Composer GUI. This parameter should not include the .ccscene file extension; for example, if the JSON file which specifies the scene asset layout is called scene1.ccscene, this parameter should be simply “scene1”. Note that this parameter should only be used with scenes created within the Composer GUI — it should not be used for Composer scenes created outside of the Composer GUI.

 

Hi @mimetic,

The “newScene()” function is used for both the Composer library and the Composer GUI. In the former case, you don’t need to pass any argument. In the latter case (GUI), you should pass the .ccscene file name (without extension) as the documentation says.

Hope this helps,

Brent

So…what if I want to name a scene, so I can gotoScene?

composer.gotoScene( mySceneName )

With Storyboard, I could name the scene. With Composer, this still seems to work but it throws a “warning” that there is no .ccscene file.

Hi @mimetic,

So to clarify, are you using the Composer GUI, or simply the Composer library functions? If you’re not using the GUI, then just specify the Lua file name (without extension) in the “gotoScene()” function.

Brent

Yeah, that’s the problem. I’m converting from Storyboard, and I had multiple scene handlers in the one file, not in each scene in a lua files, e.g. not in myscene.lua.

Composer is forcing me to break up the code into files, I think.

That’s is one reason I wanted to be able to access each scene by name without specifying a file, only a name.

Composer should still support the idea of multiple scenes in a single file, though I’m not sure the complexity added to support multiple scenes in one file (which includes longer source files) is worth the value of having fewer lua files or addressing scope issues that can easily be managed other ways.

We also use that parameter to load in Composer GUI files. I see two options, put things in separate files or live with the warning messages.  Or are you saying passing in a name for doing multiple scenes and it’s not working (other than the warning?)

Rob

Rob, I wrote a complete “dialog” module which allows for complex dialog boxes. It used storyboard. I’m trying to use composer, now, since storyboard will be discarded.

That is why I had multiple scenes in a file — they are dynamically created from parameters. I could have “dialog.lua” scene file which built itself based on the params — moving that chunk of code out of the main code. I didn’t want to completely rebuild the whole thang, but I don’t see another way. It’s a ton of work I’d prefer not to do!

I’ll see if composer is OK with creating new named windows w/o a .lua file.

Thanks for the support.

@mimetic, why don’t you stick with storyboard ? Even if its deprecated, you have access to the source code and if storyboard give you everything you need, maybe you could avoid more work.
 

Is that safe? I was worried the module would disappear, and I would not have access. Anyone know if Storyboard will disappear from the Corona code base?

I also wonder if rebuilding using a better structure is worth the investment? Hard to tell…

Meanwhile, my previously working code is crashing, showing an error in storyboard.showOverlay! I guess that’s why I’m trying got transition to composer.

Jul 15 10:53:15.837: Runtime error ?:0: attempt to index upvalue '?' (a nil value) stack traceback: ?: in function 'showOverlay' /Volumes/Macintosh HD/Users/dgross/Corona Projects/photobook/scripts/dialog/dialog.lua:1600: in function 'showWindow'

Its in the CoronaLabs github : https://github.com/coronalabs/framework-storyboard-legacy. So you can include it in your project.

Great! Thanks! 

Meanwhile, I discovered the bugs that caused me to switch were related to missing files used in Widgets, not to Storyboard at all. Turns out, Widgets do not tell you what the problem is when a file is missing — you just get mysterious errors with no references to functions or cause.

We made storyboard.lua available on Github as @nmichaud said. Simply drop it into the folder with your main.lua and even if we get rid of it, you would still have it.  That said, we will not be updating storyboard.lua any more. If do something like we did with Graphics 2.0 where it had breaking changes and those changes break storyboard.lua, you’re on your own to update it.  Composer is the supportable path going forward.

Rob

Hi @mimetic,

The “newScene()” function is used for both the Composer library and the Composer GUI. In the former case, you don’t need to pass any argument. In the latter case (GUI), you should pass the .ccscene file name (without extension) as the documentation says.

Hope this helps,

Brent

So…what if I want to name a scene, so I can gotoScene?

composer.gotoScene( mySceneName )

With Storyboard, I could name the scene. With Composer, this still seems to work but it throws a “warning” that there is no .ccscene file.

Hi @mimetic,

So to clarify, are you using the Composer GUI, or simply the Composer library functions? If you’re not using the GUI, then just specify the Lua file name (without extension) in the “gotoScene()” function.

Brent

Yeah, that’s the problem. I’m converting from Storyboard, and I had multiple scene handlers in the one file, not in each scene in a lua files, e.g. not in myscene.lua.

Composer is forcing me to break up the code into files, I think.

That’s is one reason I wanted to be able to access each scene by name without specifying a file, only a name.

Composer should still support the idea of multiple scenes in a single file, though I’m not sure the complexity added to support multiple scenes in one file (which includes longer source files) is worth the value of having fewer lua files or addressing scope issues that can easily be managed other ways.

We also use that parameter to load in Composer GUI files. I see two options, put things in separate files or live with the warning messages.  Or are you saying passing in a name for doing multiple scenes and it’s not working (other than the warning?)

Rob

Rob, I wrote a complete “dialog” module which allows for complex dialog boxes. It used storyboard. I’m trying to use composer, now, since storyboard will be discarded.

That is why I had multiple scenes in a file — they are dynamically created from parameters. I could have “dialog.lua” scene file which built itself based on the params — moving that chunk of code out of the main code. I didn’t want to completely rebuild the whole thang, but I don’t see another way. It’s a ton of work I’d prefer not to do!

I’ll see if composer is OK with creating new named windows w/o a .lua file.

Thanks for the support.

@mimetic, why don’t you stick with storyboard ? Even if its deprecated, you have access to the source code and if storyboard give you everything you need, maybe you could avoid more work.
 

Is that safe? I was worried the module would disappear, and I would not have access. Anyone know if Storyboard will disappear from the Corona code base?

I also wonder if rebuilding using a better structure is worth the investment? Hard to tell…

Meanwhile, my previously working code is crashing, showing an error in storyboard.showOverlay! I guess that’s why I’m trying got transition to composer.

Jul 15 10:53:15.837: Runtime error ?:0: attempt to index upvalue '?' (a nil value) stack traceback: ?: in function 'showOverlay' /Volumes/Macintosh HD/Users/dgross/Corona Projects/photobook/scripts/dialog/dialog.lua:1600: in function 'showWindow'