Game Development Community

Layering GUI controls

by Brandon · in Torque X 2D · 01/27/2009 (4:38 pm) · 2 replies

I want to have different controllers for the text and the GUI bitmaps, but for some reason the bitmap covers the text. I see in the GUIText and GUIBitmap there is a layer property, but that doesn't seem to do anything when I set it.

Any idea how I can put my bitmap controller behind my text controller?

#1
01/27/2009 (9:39 pm)
Try setting the buttons to be children of the bitmaps. For example, I currently have a GUIBitmap that serves as the background for my menu and then I have a bunch of GUIButtons on top of the bitmap. Here's some code (pretty much taken from the FPS Demo):

// Setup our bitmap
GUIBitmap baseFrame = new GUIBitmap();
baseFrame.Style = bitmapStyle; // Defined elsewhere.  Omitted for clarity.
baseFrame.HorizSizing = HorizSizing.Center;
baseFrame.VertSizing = VertSizing.Center;
baseFrame.Bitmap = @"data\your\background\image";
baseFrame.Visible = true;
// _root is the GUIControl that holds everything in the GUI
baseFrame.Folder = _root;

// Setup a button
GUIButton item = new GUIButton();
item.Style = buttonStyle; // Defined elsewhere.  Omitted for clarity.
item.ButtonText = "Your Button Text";
item.Position = Vector2.Zero;
item.Visible = true;
item.Size = new Vector2(500, 60);
item.Folder = baseFrame; // <-- makes our button a child of our bitmap
#2
01/28/2009 (7:32 am)
Yep that works. Thanks!