Simple Energy and Heatlth GUI Objects
by Harold "LabRat" Brown · 09/07/2001 (10:28 am) · 4 comments
Download Code File
4 new GUI controls:
Player Energy
Player Health
Vehicle Energy
Vehicle Health
Add the .cc and .h files to gui folder in the appropriate sections.
You will also need to add them to the makefile or the MSVC project file.
After you have done that compile a new test application
After that you will want to add the following to your base/ui/defaultProfiles.cs :
new GuiControlProfile ("GuiEnergyBarProfile")
{
opaque = false;
fillColor = "0 0 255 100";
border = true;
borderColor = "0 255 0";
};
new GuiControlProfile ("GuiHealthBarProfile")
{
opaque = false;
fillColor = "255 0 0 100";
border = true;
borderColor = "0 255 0";
};
new GuiControlProfile ("GuiVehicleEnergyProfile")
{
opaque = false;
fillColor = "0 0 255 100";
border = true;
borderColor = "0 255 0";
};
new GuiControlProfile ("GuiVehicleHealthProfile")
{
opaque = false;
fillColor = "255 0 0 100";
border = true;
borderColor = "0 255 0";
};
Once you have added those profiles you will need to add the GUI objects to your Playgui.
You can either do that with the GUI Editor. Or you can add the following befor the last "};"
at the end of your client/ui/PlayGui.gui file:
new GuiEnergyBarCtrl() {
profile = "GuiEnergyBarProfile";
horizSizing = "left";
vertSizing = "bottom";
position = "522 7";
extent = "105 16";
minExtent = "8 8";
visible = "1";
helpTag = "0";
};
new GuiHealthBarCtrl() {
profile = "GuiHealthBarProfile";
horizSizing = "left";
vertSizing = "bottom";
position = "522 28";
extent = "105 16";
minExtent = "8 8";
visible = "1";
helpTag = "0";
};
new guiVehicleEnergyCtrl() {
profile = "GuiEnergyBarProfile";
horizSizing = "right";
vertSizing = "top";
position = "79 456";
extent = "105 16";
minExtent = "8 8";
visible = "1";
helpTag = "0";
};
new guiVehicleHealthCtrl() {
profile = "GuiHealthBarProfile";
horizSizing = "left";
vertSizing = "top";
position = "461 456";
extent = "105 16";
minExtent = "8 8";
visible = "1";
helpTag = "0";
};
4 new GUI controls:
Player Energy
Player Health
Vehicle Energy
Vehicle Health
Add the .cc and .h files to gui folder in the appropriate sections.
You will also need to add them to the makefile or the MSVC project file.
After you have done that compile a new test application
After that you will want to add the following to your base/ui/defaultProfiles.cs :
new GuiControlProfile ("GuiEnergyBarProfile")
{
opaque = false;
fillColor = "0 0 255 100";
border = true;
borderColor = "0 255 0";
};
new GuiControlProfile ("GuiHealthBarProfile")
{
opaque = false;
fillColor = "255 0 0 100";
border = true;
borderColor = "0 255 0";
};
new GuiControlProfile ("GuiVehicleEnergyProfile")
{
opaque = false;
fillColor = "0 0 255 100";
border = true;
borderColor = "0 255 0";
};
new GuiControlProfile ("GuiVehicleHealthProfile")
{
opaque = false;
fillColor = "255 0 0 100";
border = true;
borderColor = "0 255 0";
};
Once you have added those profiles you will need to add the GUI objects to your Playgui.
You can either do that with the GUI Editor. Or you can add the following befor the last "};"
at the end of your client/ui/PlayGui.gui file:
new GuiEnergyBarCtrl() {
profile = "GuiEnergyBarProfile";
horizSizing = "left";
vertSizing = "bottom";
position = "522 7";
extent = "105 16";
minExtent = "8 8";
visible = "1";
helpTag = "0";
};
new GuiHealthBarCtrl() {
profile = "GuiHealthBarProfile";
horizSizing = "left";
vertSizing = "bottom";
position = "522 28";
extent = "105 16";
minExtent = "8 8";
visible = "1";
helpTag = "0";
};
new guiVehicleEnergyCtrl() {
profile = "GuiEnergyBarProfile";
horizSizing = "right";
vertSizing = "top";
position = "79 456";
extent = "105 16";
minExtent = "8 8";
visible = "1";
helpTag = "0";
};
new guiVehicleHealthCtrl() {
profile = "GuiHealthBarProfile";
horizSizing = "left";
vertSizing = "top";
position = "461 456";
extent = "105 16";
minExtent = "8 8";
visible = "1";
helpTag = "0";
};
About the author
#2
05/28/2002 (5:25 am)
Hey guys, I finally tried adding these about a week ago and got the same error you did Nick. Find out the reason?
#3
06/11/2002 (5:59 pm)
take out the last variable and rebuild
#4
09/29/2002 (10:54 pm)
Do you find that with the default player datablock, the one that comes with 1_1_2, that your energy bar drains and recharges way too fast? I am having this problem. And changing the values for energy drain don't seem to make any difference. Any ideas? 
Torque Owner Nick Carnevalino
now i am having a more sirous problem
C:\torque\engine\health_energy.bars\guiEnergyBarCtrl.cc(66) : error C2660: 'renderChildControls' : function does not take 3 parameters
now i just have to ind that function and see where the problem lies :-)