Page 1 of 1

Healthbar won't decrease

PostPosted: Mon Apr 30, 2012 6:52 am
by raminkhan
Hi I have a healthbar with this code below but how can I have it decrease the bar which is in animpos of 8.

here's my code:

hp_timer++; //this is my timer which makes the health bar increase in 30 seconds.
if(hp_timer>30 && hp<max_hp)
{
hp++; // this is what increases my health bar
hp_timer=0;
}

animpos=8;

Re: Healthbar won't decrease

PostPosted: Mon Apr 30, 2012 8:17 am
by phyzix5761
Not quite sure what you are asking for but you could write a similar code which includes the line

animpos-=1;

Re: Healthbar won't decrease

PostPosted: Mon Apr 30, 2012 3:54 pm
by skydereign
You are using a variable, to store hp right? Then you need to set animpos equal to the variable. Currently you are just setting animpos equal to 8 at the end of that script (which means the bar won't look like it changes).

Re: Healthbar won't decrease

PostPosted: Wed May 23, 2012 11:08 am
by savvy
Code: Select all
hp_timer++; //this is my timer which makes the health bar increase in 30 seconds.
if(hp_timer>30 && hp<max_hp)
{
hp++; // this is what increases my health bar
hp_timer=0;
}
animpos=hp;


savvy

EDIT: I just realised, ++ and 30 wont make 30 seconds either, it will be increasing once a second, 30fps means the hp_timer will increase 30times per second.
For 30 seconds it needs to be hptimer>300.