Jump to content


Photo

How Do You Make Health Bar Above Player/enemy?


  • Please log in to reply
10 replies to this topic

#1 shadowman465

shadowman465

    GMC Member

  • New Member
  • 244 posts

Posted 26 December 2008 - 09:36 PM

Hi I know how to make a healthbar but.. how do you make it float above the player and i want to have another health bar above my enemy

Thanks Ill give credit if you can help
  • 0

#2 chao master

chao master

    GMC Member

  • New Member
  • 36 posts

Posted 26 December 2008 - 09:41 PM

Easy peasy lemon squezy
In the draw event of the ememy and of the player place the following code
draw_healthbar(x,y-20,x+100,y-10,Inset health varible here,c_black,c_red,c_green,0,true,true)
draw_sprite(sprite_index,-1,x,y)

There you go. You might want to adjust the positions of it
Ask if u need anymore help.
  • 0

#3 WMCD

WMCD

    Spritist

  • GMC Member
  • 1410 posts
  • Version:GM5

Posted 26 December 2008 - 09:57 PM

if you're wondering, in this code, x1 and y1 are the coordinates of the top-left corner of the healthbar, while x2 and y2 are for the bottom-right corner.

Posted Image

^sorry, couldn't resist ^_^

EDIT:

Hi I know how to make a healthbar but..



oh,well, I guess you already knew...

Edited by Old School Gaming, 26 December 2008 - 10:06 PM.

  • 0

#4 oliverzhang1

oliverzhang1

    GMC Member

  • New Member
  • 1 posts

Posted 11 June 2009 - 09:39 AM

i haven't learned GML yet... can any one help on making a health bar and making it hover above me?
(i have lite) :)
  • 0

#5 dawarrior333

dawarrior333

    GMC Member

  • New Member
  • 436 posts

Posted 11 June 2009 - 10:10 AM

i haven't learned GML yet... can any one help on making a health bar and making it hover above me?
(i have lite) :)

Alright add the draw health bar drag&drop in to he draw event.
put this in.
x1 = x+5
y1 = y+5
x2 = x+100
y2 = y-5
back color = black
bar color = green to red
This should make a nice health bar on lite
  • 0

#6 the-ex1

the-ex1

    GMC Member

  • New Member
  • 22 posts

Posted 16 December 2010 - 12:08 PM

draw_healthbar(x,y-20,x+100,y-10,Inset health varible here,c_black,c_red,c_green,0,true,true)
draw_sprite(sprite_index,-1,x,y)
i made this but when my hero hit enemy its healthbar is not going low :(
  • 0

#7 Yevez

Yevez

    GMC Member

  • GMC Member
  • 30 posts
  • Version:GM8

Posted 19 March 2011 - 12:43 AM

draw_healthbar(x,y-20,x+100,y-10,Inset health varible here,c_black,c_red,c_green,0,true,true)
draw_sprite(sprite_index,-1,x,y)
i made this but when my hero hit enemy its healthbar is not going low :(

it is easy to fix
MAke a collision event on enemy then set your health variable to -1 and click relative
  • 0

#8 _191735

_191735

    GMC Member

  • New Member
  • 25 posts

Posted 19 March 2011 - 04:43 AM

If you want multiple health bars, I think you have to make them yourself and not use the built-in Health functions. If I'm correct, there's only one health bar built-in, and it's for the player. If you want a healthbar for the enemies as well, just make your own. Make a healthbar sprite and add a few subimages to it (to show health dropping), set a "health" variable in the create event of an object, and every time there is a collision with something bad, change the subimage to one that shows less health and set the "health" variable to -1 relative. Also, have the object draw the "health" variable as text within the healthbar, like "HP: 7/10"

There are several ways of doing this, but I just listed one way
  • 0

#9 Superadam051

Superadam051

    GMC Member

  • GMC Member
  • 67 posts
  • Version:GM8.1

Posted 01 April 2013 - 08:41 PM

draw_healthbar(x,y-20,x+100,y-10,Inset health varible here,c_black,c_red,c_green,0,true,true)
draw_sprite(sprite_index,-1,x,y)
i made this but when my hero hit enemy its healthbar is not going low sad.gif

it is easy to fix
MAke a collision event on enemy then set your health variable to -1 and click relative

Doesn't seem to work for me. 


  • 0

#10 Lemonpuss

Lemonpuss

    GMC Member

  • New Member
  • 1 posts
  • Version:GM8.1

Posted 15 May 2013 - 10:34 PM

If this conversation is still active, I would like to report a problem I had with the moving health bar.

I put the event Draw in, and the draw health bar

 

x1:0

y1:0

x2:30

y2:-5

back colour: black

bar colour: green to red

set relative on

 

Now, whenever I play my game, my sprite_player turns invisible.

Is there any way to solve this?


Edited by Lemonpuss, 15 May 2013 - 10:34 PM.

  • 0

#11 loverock125

loverock125

    GMC Member

  • GMC Member
  • 1597 posts
  • Version:GM8

Posted 15 May 2013 - 10:44 PM

If this conversation is still active, I would like to report a problem I had with the moving health bar.

I put the event Draw in, and the draw health bar

 

x1:0

y1:0

x2:30

y2:-5

back colour: black

bar colour: green to red

set relative on

 

Now, whenever I play my game, my sprite_player turns invisible.

Is there any way to solve this?

 

Put draw_self() At the top of the draw event.  This is because when the draw event is used, nothing is drawn (Not even the object's own sprite).


  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users