Page 1 of 1

HpBar error?

PostPosted: Tue Jul 30, 2013 6:15 pm
by Lacotemale
I have a hp bar and other similar bars. The code to show hp as a percentage of 100% used to work but suddenly stopped working, despite not touching the code.

Does this look alright?
Code: Select all
int hpValue = ((float)CharDataArray[party[partyPos]].hp/CharDataArray[party[partyPos]].maxHp)*100;


If I manually set hpValue to a number it will display, so the problem is with the calculation I suspect. :?

Re: HpBar error?

PostPosted: Wed Jul 31, 2013 3:17 am
by skydereign
Lacotemale wrote:stopped working, despite not touching the code.

What actually happens? The casting to float should preserve the floating point, and therefore the math is right. If your first frame of the animation is completely invisible, gE won't create it correctly on game mode start, which might be the problem.

Re: HpBar error?

PostPosted: Wed Jul 31, 2013 8:27 am
by Lacotemale
The hpBar is always full. Even if its 20/30 (hp/maxHp) which should fill the bar only 66%.

If your first frame of the animation is completely invisible, gE won't create it correctly on game mode start, which might be the problem.


Im not sure what you mean. The bar is not created at startup if that is what you mean. I can change it and see if any difference.

Re: HpBar error?

PostPosted: Wed Jul 31, 2013 10:46 am
by Lacotemale
Right so the calculation I have proof is correct now via a debug output number.

However when I go to where the hpBars are displayed its always set to 100.

I will dig deeper and see can I find the cause of this.

Re: HpBar error?

PostPosted: Wed Jul 31, 2013 11:20 am
by Lacotemale
Got it sorted! Just needed separate actors instead of using one.

Its much more reliable. :D