HpBar error?

Non-platform specific questions.

HpBar error?

Postby Lacotemale » Tue Jul 30, 2013 6:15 pm

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. :?
User avatar
Lacotemale
 
Posts: 285
Joined: Wed Dec 08, 2010 7:47 pm
Location: /home
Score: 7 Give a positive score

Re: HpBar error?

Postby skydereign » Wed Jul 31, 2013 3:17 am

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: HpBar error?

Postby Lacotemale » Wed Jul 31, 2013 8:27 am

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.
User avatar
Lacotemale
 
Posts: 285
Joined: Wed Dec 08, 2010 7:47 pm
Location: /home
Score: 7 Give a positive score

Re: HpBar error?

Postby Lacotemale » Wed Jul 31, 2013 10:46 am

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.
User avatar
Lacotemale
 
Posts: 285
Joined: Wed Dec 08, 2010 7:47 pm
Location: /home
Score: 7 Give a positive score

Re: HpBar error?

Postby Lacotemale » Wed Jul 31, 2013 11:20 am

Got it sorted! Just needed separate actors instead of using one.

Its much more reliable. :D
User avatar
Lacotemale
 
Posts: 285
Joined: Wed Dec 08, 2010 7:47 pm
Location: /home
Score: 7 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron