Enemy fighting health bar

Talk about making games.

Enemy fighting health bar

Postby raminjoon » Mon Aug 15, 2011 6:22 pm

Okay I got a man standing in front of my screen facing the player which is the user. Okay now I want to install a health bar that if I shoot the man he looses health or if he's attacking me, he's gaining health on his health bar. health bar meaning like this image. attached. how can I do that?
Attachments
healthBar.PNG
healthBar.PNG (315 Bytes) Viewed 637 times
raminjoon
 
Posts: 40
Joined: Tue Jul 05, 2011 5:34 am
Location: Denver, Co.
Score: 3 Give a positive score

Re: Enemy fighting health bar

Postby JamesLeonardo32 » Mon Aug 15, 2011 8:44 pm

So lets say the healthbar has 11 frames of animation, but 10 frames with health, leaving the first frame (Frame 0) with none.
Now make an normal actor called enemyhp- add the animation making sure it has the correct amount of frames. And in the right order.

Then make an Actor vairable called something like hp, so when an enemy is created it has this script:

Code: Select all
 hp=10;


Since its an actor vairable, it relates to that single actor and not all the enemies.
When an object like a bullet collides, make a script event:

Enemy > Collision > Bullet > Script:

Code: Select all
hp-=1; //loses how much health
enemyhp.animpos=hp;


And something similar to when your attacked.

Please reply if you have any questions or if this helps!
JamesLeonardo32
 
Posts: 320
Joined: Wed Oct 13, 2010 4:57 pm
Score: 36 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest