composer.stage issue ( I think )

Hello Guys !

I am currently creating an app and wanted to have a bg image that stays for every scene.

To do that I normaly create a display.newImage in the main.lua and create all other widget / display objects within the create of the scene ( let 's say login.lua ).

But for the moment I can’t make it work : the bg image is the only thing you see !

If I set isVisible = false to to bg image I can see all of my login’s widgets …

I tried to have a global reference on composer.stage as topGroup to add the ogin’s widget in this group ( instead of the self.view group ) and it works, but I can’t have all my app like this .

I am missing something here ?

I am on windows, tries on android too with the same result.

Thanks for the help !

Personally, I would just write a couple of extra lines of code and just load the background in every scene letting Composer manage it for you rather than try and find a hackish way to have an image always in the back.

But if you only want it once, maybe try loading it in main.lua and then doing a:  toBack() API call to send it to the back of the app’s main stage.

Rob

Ok thanks Rob, I vaguely remembered about the toBack().

But still, isn’t the behaviour I described the normal behaviour as stated here in the doc :

Returns a reference to the top-level Composer display group which all scene views are inserted into. This can be considered as the “Composer scene layer” and it’s useful if you need to place display objects above or below all Composer scenes, even during transition effects. For example:

  • A background image that is displayed behind all Composer scenes and remains static, even during scene transitions.
  • A tab or UI bar that appears above all Composer scenes.
  • HUD (heads-up display) elements such as health, score, etc.

But thank you I am going with toBack() 

Ok I guess I didn’t really understood before : the composer.stage will be displayed over the current scene, I am right ?

So i guess the only option in this case is to use the toBack() ( which works perfectly now ).

The best way of achieving a constant background is insert it into the stage BEFORE anything else.  Then it will always be below your scenes.

Try this https://docs.coronalabs.com/api/library/composer/stage.html

It’s a huge layering system.  

+------ | +--------- | | Things not put into a composer group | +------- | | +--------- | | | Current Scene | | +--------- | | | Transitioning Scene | | +---------- | | | +------- Composer Stage | +------ Current Stage (outer container of all display objects.

So you should be able to access the composer stage, insert an object into it, but by default new objects go on top unless you’re doing a table.insert() to fit it in where you want it within the children table for the group, or use toBack(), toFront() to move items.

Composer wants to be the bottom of the stack and have non-managed items on top. I would think you can insert your background before you start creating scenes and it should be the back most thing in the composer stage. But you can always toBack() it.

So it should work as you’re expecting. 

Rob

Thank you for this more elaborate answer rob !

Personally, I would just write a couple of extra lines of code and just load the background in every scene letting Composer manage it for you rather than try and find a hackish way to have an image always in the back.

But if you only want it once, maybe try loading it in main.lua and then doing a:  toBack() API call to send it to the back of the app’s main stage.

Rob

Ok thanks Rob, I vaguely remembered about the toBack().

But still, isn’t the behaviour I described the normal behaviour as stated here in the doc :

Returns a reference to the top-level Composer display group which all scene views are inserted into. This can be considered as the “Composer scene layer” and it’s useful if you need to place display objects above or below all Composer scenes, even during transition effects. For example:

  • A background image that is displayed behind all Composer scenes and remains static, even during scene transitions.
  • A tab or UI bar that appears above all Composer scenes.
  • HUD (heads-up display) elements such as health, score, etc.

But thank you I am going with toBack() 

Ok I guess I didn’t really understood before : the composer.stage will be displayed over the current scene, I am right ?

So i guess the only option in this case is to use the toBack() ( which works perfectly now ).

The best way of achieving a constant background is insert it into the stage BEFORE anything else.  Then it will always be below your scenes.

Try this https://docs.coronalabs.com/api/library/composer/stage.html

It’s a huge layering system.  

+------ | +--------- | | Things not put into a composer group | +------- | | +--------- | | | Current Scene | | +--------- | | | Transitioning Scene | | +---------- | | | +------- Composer Stage | +------ Current Stage (outer container of all display objects.

So you should be able to access the composer stage, insert an object into it, but by default new objects go on top unless you’re doing a table.insert() to fit it in where you want it within the children table for the group, or use toBack(), toFront() to move items.

Composer wants to be the bottom of the stack and have non-managed items on top. I would think you can insert your background before you start creating scenes and it should be the back most thing in the composer stage. But you can always toBack() it.

So it should work as you’re expecting. 

Rob

Thank you for this more elaborate answer rob !