Plastic Gem #23: Energy Bar GUI
by Paul Dana · 07/10/2008 (3:02 pm) · 2 comments

Plastic Gem # 23 : Energy Bar GUI
Difficulty: Easy
Before you follow this gem you must follow the instructions in Gem #22 to get the jetting ability. Jetting means ability to fly around using right mouse to activate a jet that pushes you up into the air. If you are using TGE Advanced then you don't need to do anything as jetting comes as part of the demo.
This gem shows how to add a GUI control that will show the amount of energy the player has. As you jet around and use energy you will see the bar change.
The first step is to run the game so you can acess the GUI Editor. It helps to use a higher resolution than 800 x 600...say 1024x768 for example. First setup your game to run at that resolution or higher. Then run the game and hit F10 to access the GUI editor. From there we want to edit the PlayGUI.
NOTE: from TGE it is best to run the game and load a mission first. Then when you hit F10 the PlayGUI is already editing. I am unsure what steps are best for editing the PlayGUI from TGEA. Perhaps someone here could pipe up with advice on that?
Next you want to add a new control the GUI. The type of control is called GuiHealthBarHud. In TGE there is a button in the upper left of the GUI editor that you press to add a new control. Place one of these controls somewhere on the screen, perhaps to the side.
Now ensure that control is selected so you can edit it's fields. Find the named displayEnergy and check that field. This is where the higher resolution helps. At 800x600 the names can be cut off.
That is all there is to it! Now when you jet around and use energy you should see the energy bar drop.
The Next Gem
That is all for this gem. Next gem we will show how change your recharge rate from script as well as just give or take energy away from script.
#2
GoodLuck
08/01/2008 (7:55 am)
The 'energy' variable is stock in torque and could be applied for stamina. The gui will reflect the energy level (so that is covered) the other thing you would need to utilize (also stock in Torque) is making the ShapeBaseImages use and require energy, look in the weapon datablock properties.GoodLuck

Torque Owner Infinitum3D
Any ideas how?
Thanks!
Tony