Game Development Community

HUD help

by Kevin James · in Torque Game Builder · 06/10/2010 (10:11 am) · 2 replies

Is there a good resource or tutorial on how to add another scenewindow as a HUD? My first attempt failed miserably.

I added this after sceneWindow2D in mainScreen.gui:
new t2dSceneWindow(hudWindow) {
      canSaveDynamicFields = "0";
      Profile = "NonModalContentProfile";  
      HorizSizing = "width";
      VertSizing = "height";
      Position = "0 0";
      Extent = "800 600";
      MinExtent = "8 8";
      canSave = "1";
      Visible = "1";
      lockMouse = "0";
      useWindowMouseEvents = "1";
      useObjectMouseEvents = "1";
   };

Then I created a new level with 1 label exactly where I want it to appear in the game (and deleted that label from the main level). I added this code to game.cs:

sceneWindow2D.setUseObjectMouseEvents( true );
   sceneWindow2D.loadLevel(%level);
   
   //added hudWindow
   hudWindow.setUseObjectMouseEvents( true );
   hudWindow.loadLevel("hud.t2d");


When I run the game the label is gone. How do I show one level on top of another?

About the author

Computer security, digital forensics, and platform jumper enthusiast. shells.myw3b.net/~syreal/


#1
06/15/2010 (8:33 pm)
I do the same trick for my hud. I think the bug is that in the
hudWindow.loadLevel("hud.t2d"); line, you have to put the whole directory of your level. So it should be
hudWindow.loadLevel("game/data/levels/hud.t2d");
if your using the default location for you hud level file. Also, make sure for your hudWindow profile, you have a profile that is see through like the GuiDefaultProfile, the profile your using might be fine though.
#2
06/16/2010 (4:42 am)
Thanks William, you are exactly right! My current "HUD" uses about 12 different "Levels" to create the look and feel I want. I also noticed that the order is important. The main level should be called last.