Load scene on display object

Hello, is it possible to load a scene inside a display object like a display group or rect? For example, instead of gotoscene fills the entire screen, make it fill the display object bounds limits.

Thanks

Hi @lsoaresesilva7,

A few questions:

Does this scene (to load inside some bounds) need to be actively playing/moving/running? Or are you just trying to show a “screenshot” of how it looks?

Brent

Hi, Brent, let me explain what I’m planning to do:

  1. I’m writing a library which will show a left side menu. This menu is only shown when a button is clicked. The menu is shown as an “overlay” over the entire screen
  2. This menu must be present in all scenes (I do not know anything about those other scenes).
  3. When an item is selected on menu, its contents must be shown on screen
  4. I know I can use composer overlay, but in this context I do not have control over other composer scenes, so my intention is to show item’s scenes on my main scene.

Thanks

Composer Overlay scenes are bound to their parent and when you change scenes, the overlay is going to automatically hide on you. If this effect is okay, then you certainly can go that route. We have a sample app called CoronaWeather at https://github.com/coronalabs-samples/CoronaWeather

Look in the scenes/menu.lua and classes/ui.lua files to see how it’s setup. However if you don’t want the menu to close automatically…

Composer has an interesting feature that’s usually a source of frustration to many learning composer, but it’s what you want in this mode. Any display object **not** in the scene’s view group sits on top of everything else. We call this HUD mode,

In many apps, items like the navigation bar at the top and the tabBar controller at the bottom should always be on screen and available. Frequently these are created in main.lua and never added to any scene so they always sit on top of all scenes and are always available.  The CoronaWeather app does this as well as the Business App sample (https://github.com/coronalabs-samples/business-app-sample).  

So I would just create a display group, put your menu items in it and place it just off screen (or hide it with .alpha = 0 if you want to fade it in with transition.to or .isVisible = false if you just want it to appear) and when you menu activation button transition.to the display group on screen. When you dismiss the menu, transition it back off screen.

Rob

Wow, thanks! Using this HUD characteristic solved my problem!

Hi @lsoaresesilva7,

A few questions:

Does this scene (to load inside some bounds) need to be actively playing/moving/running? Or are you just trying to show a “screenshot” of how it looks?

Brent

Hi, Brent, let me explain what I’m planning to do:

  1. I’m writing a library which will show a left side menu. This menu is only shown when a button is clicked. The menu is shown as an “overlay” over the entire screen
  2. This menu must be present in all scenes (I do not know anything about those other scenes).
  3. When an item is selected on menu, its contents must be shown on screen
  4. I know I can use composer overlay, but in this context I do not have control over other composer scenes, so my intention is to show item’s scenes on my main scene.

Thanks

Composer Overlay scenes are bound to their parent and when you change scenes, the overlay is going to automatically hide on you. If this effect is okay, then you certainly can go that route. We have a sample app called CoronaWeather at https://github.com/coronalabs-samples/CoronaWeather

Look in the scenes/menu.lua and classes/ui.lua files to see how it’s setup. However if you don’t want the menu to close automatically…

Composer has an interesting feature that’s usually a source of frustration to many learning composer, but it’s what you want in this mode. Any display object **not** in the scene’s view group sits on top of everything else. We call this HUD mode,

In many apps, items like the navigation bar at the top and the tabBar controller at the bottom should always be on screen and available. Frequently these are created in main.lua and never added to any scene so they always sit on top of all scenes and are always available.  The CoronaWeather app does this as well as the Business App sample (https://github.com/coronalabs-samples/business-app-sample).  

So I would just create a display group, put your menu items in it and place it just off screen (or hide it with .alpha = 0 if you want to fade it in with transition.to or .isVisible = false if you just want it to appear) and when you menu activation button transition.to the display group on screen. When you dismiss the menu, transition it back off screen.

Rob

Wow, thanks! Using this HUD characteristic solved my problem!