Please! :( :( How to render buttons/etc on TOP of all else, while using Corona's "ui.lua" code?

Hi all-

I have searched everywhere for how to simply make my GUI (created using the Corona provided “ui.lua” code), and can not seem to find an answer.

A previous forum post yielded zero answers after several weeks…:frowning:

This is the last major hurdle in my test game, and it’s extremely frustrating to have such a seemingly small issue holding me back. If anyone could provide a bit of help on how to force my GUI on top, I would be extremly, extremely grateful!

PS- I understand the answer probably utilizes “Groups”, however I’m not sure how to implement this since I’m using the “ui.lua” code from Corona.

Thank you very much in advance! [import]uid: 69255 topic_id: 12970 reply_id: 312970[/import]

Yes, groups are the answer. The solution is to create two groups, one for your ui and one for the stuff you want below the ui, then insert both groups into a third, “parent” group, making sure to insert the ui group LAST. That will keep the ui objects on top no matter what you do inside either child group.

for example:

--define groups  
local bottomDisplayGroup = display.newGroup()  
local uiDisplayGroup = display.newGroup()  
local parentGroup = display.newGroup()  
  
--then insert display groups into the parent group:  
parentGroup:insert(bottomDisplayGroup)  
parentGroup:insert(uiDisplayGroup)--this is last so it will be on TOP  
  
--now you can add display objects to the bottomGroup. i.e.-  
  
box1 = display.newRect(0,0,10,10)  
bottomDisplayGroup:insert(box1)  
  
--after you create new buttons using ui.lua insert them into the ui group:  
  
uiDisplayGroup:insert(button1)  
  

You can safely insert objects into either group and since you already defined the order of the groups anything you put inside the ui group will be on top of everything you put in the bottom group. You can even have groups inside groups inside groups etc. for even finer control of what renders on top of what. Even WITHIN a group, if you want something to render on top of everything else in its group, just re-insert it into its own group again.

There is nothing that special about the objects ui.lua generates. They are regular Corona display objects and can be inserted into a group like any other display object. [import]uid: 9422 topic_id: 12970 reply_id: 47588[/import]

Hi XenonBL-

Thank you so very much for the fast and very detailed reply! I’ll implement this right away, and reply if I have any questions, but it should be fine.

Best!
gw [import]uid: 69255 topic_id: 12970 reply_id: 47754[/import]