Would it be possible to copy a scene to multiple lua files without copying all the code?

Hi guys,
Yet another question but I’m just curious:)
Would it be possible to copy an entira composer scene to multiple lua files?
So for example:
-Home.lua has all the scene and everything in it
-Scene1.lua copies and displays everything in home.lua

  • Scene2.lua does the same as scene1

Would this be possible? I’m able to make some simple modules with functions in them but this is on another level than that…

Kind regards
Bram

It’s not clear why you would want to do that?

If you have a lot of functions or complex display objects that you wish to use in multiple scenes, just put them in a module as you say.

Not exactly sure what you’re asking, but if you’re using the composer framework and your question is ‘can I reuse the stuff that was created in the Composer GUI in a different scene’, then yes. Just specify the .ccscene name without the extension

composer.newScene( "home" )

Hmm, perhaps I expressed myself wrong. So I’ve got this scene, home.lua, made with the composer (not the gui, but the composer that allows to manage scenes). Now, I want an exact replica of the scene inside home.lua. So could I make some sort of module out of the complete scene?

Either save a copy of home.lua with another name and remove the bits you don’t need, or move the bits you need in both ‘home’ and the new scene to a module file that both can access.

oh. then just put all your gui creation functions etc inside a separate module, rather than in home.lua, probably tied together with a nice ‘init’ function that returns a single group you can insert into the scene group, and require it into each file.

You’re approaching it backwards.

Create a module that does all the work you’ve got in your composer scene.

Then, from a composer scene(s) call the module functions to do the work.  

You cannot open a scene within scene.  Composer scenes are not a module in the way you’re thinking.

Note: The above is not 100% accurate.  There is always a way to do something, but in this case the way you would use one scene to build the contents of another scene… would be a total mess.

Use modules.

Alright roaminggamer, that was all I needed to know.

Thanks!

It’s not clear why you would want to do that?

If you have a lot of functions or complex display objects that you wish to use in multiple scenes, just put them in a module as you say.

Not exactly sure what you’re asking, but if you’re using the composer framework and your question is ‘can I reuse the stuff that was created in the Composer GUI in a different scene’, then yes. Just specify the .ccscene name without the extension

composer.newScene( "home" )

Hmm, perhaps I expressed myself wrong. So I’ve got this scene, home.lua, made with the composer (not the gui, but the composer that allows to manage scenes). Now, I want an exact replica of the scene inside home.lua. So could I make some sort of module out of the complete scene?

Either save a copy of home.lua with another name and remove the bits you don’t need, or move the bits you need in both ‘home’ and the new scene to a module file that both can access.

oh. then just put all your gui creation functions etc inside a separate module, rather than in home.lua, probably tied together with a nice ‘init’ function that returns a single group you can insert into the scene group, and require it into each file.

You’re approaching it backwards.

Create a module that does all the work you’ve got in your composer scene.

Then, from a composer scene(s) call the module functions to do the work.  

You cannot open a scene within scene.  Composer scenes are not a module in the way you’re thinking.

Note: The above is not 100% accurate.  There is always a way to do something, but in this case the way you would use one scene to build the contents of another scene… would be a total mess.

Use modules.

Alright roaminggamer, that was all I needed to know.

Thanks!