Duplicate composer scene to transition to multiple of the same scenes

I’m creating a reference guide, and when the user is in a reference scene, I want him to be able to swipe left or right to go to the next reference item in the list. All reference items are shown in a scene called: scrn_reference_item.lua

Since it is not possible to use two times the same scene after eachother and I want them to transition nicely (like switching images). I figured I could just duplicate scrn_reference_item.lua to scrn_reference_item2.lua and toggle between the two. This works, but requires me to manually dublicate the scene everytime I make an update to it, which is tiresome.

Is there a way to duplicate the original scrn_reference_item.lua at the start of the game.

I tried in main.lua to this, but that didn’t work.

scrn_reference_item2 = require(“scrn_reference_item”)

Any help or hints to a better solution are helpfull!

thanks

Hi @martijnreintjes,

Can you post some more code re: how you’re setting this up? You should be able “require” the content from a module within any scene, so I’m not sure why your approach isn’t working.

Best regards,

Brent

I had a similar need and implemented a solution staying inside one scene but juggling multiple scrollViews in and out of view.

You keep 3 active scrollviews. One with current info presented. one to its left and one to its right. You lock the scrollviews for horizontal scrolling and then borrow the x-axis touch based moving of image code from photo album in Business App Sample. Using that code you bring one scrollview out while you bring the other one in. 

Then when the old one is out of sight you refresh the data in it such that the new one becomes middle scrollview and the other two left & right. Hope this makes some sense and helps. Its just an option.

That’s also a really cool solution Ksan, I’ll give that a shot in my next update of the app, since now, it’s not really working as smoothly as I would like it to. Great idea!

You could also wrap the whole scene module in a function and use different names for each scene you create. Then you can have refScene1 and refScene2 that are created from the same module and with same properties, functionality. You can then transition between them without a problem.

Hi @martijnreintjes,

Can you post some more code re: how you’re setting this up? You should be able “require” the content from a module within any scene, so I’m not sure why your approach isn’t working.

Best regards,

Brent

I had a similar need and implemented a solution staying inside one scene but juggling multiple scrollViews in and out of view.

You keep 3 active scrollviews. One with current info presented. one to its left and one to its right. You lock the scrollviews for horizontal scrolling and then borrow the x-axis touch based moving of image code from photo album in Business App Sample. Using that code you bring one scrollview out while you bring the other one in. 

Then when the old one is out of sight you refresh the data in it such that the new one becomes middle scrollview and the other two left & right. Hope this makes some sense and helps. Its just an option.

That’s also a really cool solution Ksan, I’ll give that a shot in my next update of the app, since now, it’s not really working as smoothly as I would like it to. Great idea!

You could also wrap the whole scene module in a function and use different names for each scene you create. Then you can have refScene1 and refScene2 that are created from the same module and with same properties, functionality. You can then transition between them without a problem.