Display health bar?
by Denis Linardic · in Torque Game Builder · 10/15/2005 (10:00 am) · 8 replies
Hi Guys.
Do you know of any resource, or have idea how to create health bar in T2D?
I setup player shields and everything works fine but I need a way to show that outside of console.
It doesen't have to be bitmap, it could be numbers or anything else as long is outside of console!
Maybe showing text after player gets hit (but I have no idea how to do that). So I am asking for a few pointers.
Thanks in advance!
Denis
Do you know of any resource, or have idea how to create health bar in T2D?
I setup player shields and everything works fine but I need a way to show that outside of console.
It doesen't have to be bitmap, it could be numbers or anything else as long is outside of console!
Maybe showing text after player gets hit (but I have no idea how to do that). So I am asking for a few pointers.
Thanks in advance!
Denis
About the author
#2
%healthBarSprite.setSizeX( %player.health );
Also
check out this resource for making fancier bitmap text-base sprites
10/15/2005 (11:43 am)
If you wanted to make a *bar* instead of text, you could use a square bitmap, with horizontal gradient color, if you wanted to get fancy. Then create a staticSprite out of it and then set the X size during the game to scale it into a rectangular bar.%healthBarSprite.setSizeX( %player.health );
Also
check out this resource for making fancier bitmap text-base sprites
#3
10/16/2005 (7:34 am)
Thanks Alex! I will need to create real bar, right now I am prototyping so I make all this things simple.
#4
function player::modifyLife(%this)
{
%this.life -= getRandom(20);
if(%this.life > 100)
{
%this.life = 100;
} else if (%this.life < 0)
{
%this.explode();
}
%lifebar.setSizeX(%this.life);
}
06/30/2006 (10:48 pm)
I can't get this to work. I made a rectangle. I can see it while I'm playing the game, but I can't get it to resize. It's an image map. I gave it a name "lbar" and a class "lifebar". I gave the player a dynamic field, LIFE, and that decreases just fine, but I can't get the lifebar to resize as the player's LIFE decreases. Please help.function player::modifyLife(%this)
{
%this.life -= getRandom(20);
if(%this.life > 100)
{
%this.life = 100;
} else if (%this.life < 0)
{
%this.explode();
}
%lifebar.setSizeX(%this.life);
}
#5
04/08/2007 (7:44 pm)
@Jeffrey -- I don't know if you already figured this out or not, but just take out that '%' in front of lifebar. Like this:function player::modifyLife(%this)
{
%this.life -= getRandom(20);
if(%this.life > 100)
{
%this.life = 100;
} else if (%this.life < 0)
{
%this.explode();
}
[b]lifebar.setSizeX(%this.life);[/b]
}
#6
If you want the bar to be a different size, you can use percents, instead of just using the value of %this.life.
04/10/2007 (1:16 pm)
You should use "lbar" instead of "lifebar", keeping in mind what Kevin Epps said.If you want the bar to be a different size, you can use percents, instead of just using the value of %this.life.
#7
Thanks, Kevin for clarifying that! :)
I totally forgot that he said that he gave it the name "lbar".
04/10/2007 (1:20 pm)
Oh yeah! Right!Thanks, Kevin for clarifying that! :)
I totally forgot that he said that he gave it the name "lbar".
#8
Hopefully Jeffrey figured it out, considering that his last post is from almost a year ago.
04/11/2007 (1:25 pm)
Lol.Hopefully Jeffrey figured it out, considering that his last post is from almost a year ago.
Torque Owner Denis Linardic
Checkout this resource if you have similiar problem!