Game Development Community

Rotating a GUI element

by Alistair Lowe · in Torque Game Builder · 01/27/2011 (3:16 am) · 5 replies

Hi guys, is this possible?

Otherwise what's the most effective way to keep an ingame object static to the camera?

Many thanks

#1
01/28/2011 (7:02 am)
I don't think it is possible to rotate a guiControl, if it's what you mean by GUI element. It will maintain it's orientation on the screen, no matter what you do.

If you have your GUI made of sceneObjects, such as sprites, you can add another window to mainScreenGui just for them. Then camera movement in the original window (sceneWindow2D) will not be able to affect your GUI.
#2
01/30/2011 (1:48 pm)
Rpahut, are there any tutorials for that or any forum posts for reference?

Thanks!
#3
01/31/2011 (3:10 pm)
Likewise it's great that it's possible to do this, an example would be very helpful.

Cheers
#4
01/31/2011 (3:51 pm)
If you have the source, then check this out:

www.garagegames.com/community/forums/viewthread/109707

It allows you to have multiple scene windows overlaying each other. The top layer can get object events, the bottom most layer can use object events and/or window events.
#5
02/01/2011 (1:34 am)
Sorry, I've been away for a while.

I have mainScreen.gui file under /game/gui/, and heres it's contents:
//--- OBJECT WRITE BEGIN ---
%guiContent = new GuiControl(mainScreenGui) {
   canSaveDynamicFields = "0";
   Profile = "GuiBlackContentProfile";
   HorizSizing = "width";
   VertSizing = "height";
   Position = "0 0";
   Extent = "1024 768";
   MinExtent = "8 8";
   canSave = "1";
   Visible = "1";
   useVariable = "0";

   new t2dSceneWindow(sceneWindow2D) {
      canSaveDynamicFields = "0";
      Profile = "GuiContentProfile";
      HorizSizing = "width";
      VertSizing = "height";
      Position = "0 0";
      Extent = "1024 768";
      MinExtent = "8 8";
      canSave = "1";
      Visible = "1";
      lockMouse = "0";
      useWindowMouseEvents = "1";
      useObjectMouseEvents = "1";
   };
   
   new t2dSceneWindow(HUDWindow2D) { // this window was added by me
      canSaveDynamicFields = "0";
      Profile = "HUDWindowProfile";
      HorizSizing = "width";
      VertSizing = "height";
      Position = "0 0";
      Extent = "1024 768";
      MinExtent = "8 8";
      canSave = "1";
      Visible = "1";
      lockMouse = "0";
      useWindowMouseEvents = "1";
      useObjectMouseEvents = "1";
   };
};
//--- OBJECT WRITE END ---

You'll probably want to create your own profile for new window, mine looks like this:
if(!isObject(HUDWindowProfile)) new GuiControlProfile (HUDWindowProfile)
{      
    modal = true;      
    opaque = false;
};

Scene gets loaded to the sceneWindow2D window as usual, HUD objects are created and added to HUDWindow2D by scripts.

Also some custom mouse events processing is needed if you want to deliver them to the objects in the bottom (sceneWindow2D) window.