Game Development Community

Adding a Healthbar

by Do Not Delete · in Torque X 2D · 04/24/2007 (9:10 am) · 6 replies

I'm following [url=http://xnadevelopment.com/tutorials/notsohealthy/NotSoHealthy.shtml"]this[/url] and I was wondering which part of the code in Game.cs do I have to put the tutorial's code at.

#1
04/24/2007 (10:23 am)
It's best not to cross post.
According to your other post, it seems that your getting confused between XNA and TorqueX. The tutorial you posted to is to do with pure XNA and nothing to do with TX. The suggestion regarding the health bar has been made in the other post is a good way of doing it. I recommend you go through the Blaster tutorial in the TorqueX documentation to get a feel using TorqueX.
#2
04/24/2007 (11:39 am)
Where would the blaster tutorial be?
#3
04/24/2007 (11:57 am)
C:\Program Files\GarageGames\Torque X\v1.0.4.2\Docs
#4
04/30/2007 (3:15 am)
I have a question on health bars, whats the best way to make one thats not a rectangle? So say my health bar looks like this:

img405.imageshack.us/img405/5817/shieldbarjk0.png
Naturally with a rectangle you can just resize the bitmap as per the health value, but in this situation I guess I need to somehow hide the 'used health' under another layer?
#5
04/30/2007 (10:23 am)
That would be correct. Essentially, make two images of the same size. One would be the 'frame' and the other would be the health bars. The frame would have the section of the image you want the health bar image to show up transparent and the rest of the image opaque.

When you render, you would render the health bar image first, and then the frame image on top.

To increment or decrement the health bar, you would want to write a special gui control that rendered a clipped bitmap. That is, render the image in such a way that it doesn't stretch the image, but clips it at the desired width.
#6
06/07/2007 (5:50 am)
I finally got round to getting this working (thanks for the suggestion Rob), could i suggest that stretching the bitmap becomes an option at least for GUIBitmap?

Seems a bit wasteful to make a custom GUI control where the only difference from GUIBitmap is that one uses DrawUtil.BitmapStretch and the other uses DrawUtil.Bitmap.