Game Development Community

Adding a Health Bar

by Do Not Delete · in Torque X 2D · 04/22/2007 (5:48 pm) · 4 replies

I'm following this and I was wondering which part of the code in Game.cs do I have to put the tutorial's code at.

#1
04/22/2007 (11:37 pm)
Assuming you're interested in using TorqueX, you would probably wan't to do it differently than the pure XNA of that tutorial. TorqueX is built on top of XNA and offers much more powerfull API for doing simple things like that. A simple way of creating a health bar would to create the sprite in the TGBX editor and the edit the ".Size"-property of that in your code. But I'd really recommend that you create one of the TorqueX examples like StarterGame or SpaceShooter, and start exploring.
#2
04/23/2007 (7:24 am)
I'm working with the TankBuster starter kit.
#3
04/24/2007 (9:09 am)
Can anyone help?
#4
04/24/2007 (2:20 pm)
You can't use that code.

Just drop a health sprite into the scene. And then write a component that will keep the health bar in visibility of the camera. Then write some code that makes sure the health bar's .Size property is propotional to your target objects "health" property.

it should be fairly simple. But if you can't do that, then I would recomend just trying to "use" the size property. Open up a starterkit and start messing around. See if you can assign different sizes to the GG logo.