Game Development Community

GUI element sorting weirdness

by Matias Kiviniemi · in Torque X 2D · 06/04/2007 (1:20 am) · 3 replies

Hi,

I have a GUISceneView control with a GUIBitmap and GUIText subcontrols, and I want to display them with the text on top. What I do is I create them both, set them to the GUISceneView and tell

GUISceneView.BringObjectToFront(GUIText);

In debugger I can see that this changes the GUIText to first one in GUIControl._objects

This has worked before, but for some reason the text is always under. I don't change the order in code after the creation, but are there other things that can affect the order of items (.Awaken()/.Sleep()). Or am I missing something else?

Matias

#1
06/08/2007 (11:53 pm)
If the text is fully contained in the bitmap you could set the GUIBitmap to be the folder of the GUIText. Otherwise, I'd try switching the order you set their folders (text should be first if it isn't). I haven't actually run into this before, but I normally have seperate controls for HUD overlays.
#2
06/09/2007 (8:26 am)
Setting the GUIText folder to bitmap worked, but I actually have several bitmaps that get turned on/off depending on the state (it's a custom control). So I would have to swap the the folder dynamically, which worked but is a kind of a hairy solution..

What seems to have been the problem was actually the "BringObjectToFront" as it actually sends it to bottom (and PushObjectToBottom brings it to front)! So, setting the folder in a "deepest first-topmost last"-order sets them to a right order (in TorqueFolder._objects the last/topmpost has the highest index).

I'm not sure if the confusion is in me or Torque ;)

Matias
#3
06/09/2007 (8:37 am)
Yep - BringObjectToFront() actually sends GuiControls to back.
yay!