HOWTO - create a KOF like life bar[answered
by Chok Wei Tat · in Torque Game Builder · 10/15/2006 (5:33 am) · 2 replies
Hi, may some one give a helping hand on how to create a KOF(king of figther)/warcraft like life bar?
A rectangular, with another rectangular inside and is filled, which can reduce the width when the life reduced
Thanks
A rectangular, with another rectangular inside and is filled, which can reduce the width when the life reduced
Thanks
Torque 3D Owner Richard McKinney
Default Studio Name
(currentLife / totalLife == extentTicks / totalTicks)
extentTicks = currentLife * totalTicks / totalLife
So you could use:
LifeBarCurrent.extent = (currentLife * getWord (LifeBarEmpty.extent, 0) / totalLife) SPC getWord (LifeBarCurrent.extent, 1)
For example if you have between 0 and 100 life and your life bar is 250 pixels wide, each hit point is worth 2.5 pixels. If they take 2hp damage, the new extent of LifeBarCurrent is 98 * 250 / 100 == 245.
Works the same with sprites using t2dStaticSprites and the size property instead of extent.