Game Development Community

Flipping the Fill Direction

by Kirby Webber · in Torque Game Engine · 08/15/2004 (12:01 pm) · 9 replies

Hello everyone,

I have a rather silly problem that I cannot seem to figure out.

I've been reworking my HUD as of late and part of the redesign calls for my energy meter to be mirrored on both side of the HUD.

Basically, the left side meter is a completely stock guiVehcileHealthBar with the show energy variable set to true - they are horizontal meters as opposed to vertical.

The right side meter should be identical EXCEPT that it should decrement from left to right instead of right to left.

Any thoughts on how this could be done in script?

#1
08/16/2004 (1:08 am)
In script it may be difficult. It would be a very easy C++ change, though.
#2
08/16/2004 (5:48 am)
Well - I had looked into the guiHealthBarHud.cc file, and I think I located the code block that fills the meter. The problem I see with this is, one, it's completely a mathematical function and I'm not sure I understand exactly how it works, which leads me to two: FUD. Fear, uncertainty and doubt. =P

I would readily welcome any suggestions on how you'd go about this, specifically how you'd differentiate between the two meters to get them to "mirror" one another.

~And thanks for the reply Ben. =)
#3
08/16/2004 (9:04 am)
I believe it would be something like this
if(mMirrored)
   rect.point.x = (S32)(rect.extent.x - (rect.extent.x * mValue));
else    
   rect.extent.x = (S32)(rect.extent.x * mValue);

I don't have access to my compiler to test it right now though.

mMirrored would have to be a field you add and set in the gui.
#4
08/16/2004 (9:13 am)
Two changes. First, you need to add a script-accessible field. So in the class { } block, add this line...

bool mFlipped;

In the constructor, add this line:

mFlipped = false;

...

Ah, heck, I'll just add it to HEAD. It's a useful enough feature. Do an update in a few hours and it should be there.

:)
#5
08/16/2004 (10:03 am)
Ah, heck, you're great Ben :)
#6
08/16/2004 (10:42 am)
:-0

You rock! ~ Now for the 27 "other" features I need for my project... LMAO!

Awesome - simply awesome.
#7
08/16/2004 (10:48 am)
Ok, it's in. Console variable is called flipped. Set it to true to flip the direction of the bar.
#8
08/17/2004 (5:34 am)
You rock Ben!

~Did I mention that you just plain rock?!

=)
#9
08/17/2004 (6:27 am)
That does rock Ben, thanks.