Health HUD

Nuff

  • Posts: 9
How do you do that, and is there an example of some sort on stencylforge?
I can get a bar above the player to show how much health is left by drawing some rectangles, but I can't seem to figure out how to fix that to the screen.

coleislazy

  • *
  • Posts: 2607
Use the block "anchor [Self] to screen" under Actor->Draw. You only need to use it once, in the "when created" wrapper.

Nuff

  • Posts: 9
Um...but I'm currently using drawn rectangles for the health bar. I don't think there's a way to give the rectangles a behavior.

It's okay, I'll swap to actors.
But how do you let actors know about the value of an attribute of another actor?

Miasmos Games

  • Posts: 878
Are you using a game attribute for the health? It's generally advisable as it means you can access it (easily) from anywhere in the game. Otherwise I'd recommend simply taking a look at the Enhanced Health Pack (or some variation on that name) on Stencyl Forge.

Cupcake Bounce

coleislazy

  • *
  • Posts: 2607
Oh, if you're drawing to the screen, just draw at X + X of camera and Y + Y of camera.

Rawr

  • Posts: 85
Alright, thanks.
I got it to work.

Another question though:
For another game.
I made an actor for the health that displays different animations (ex. smiling face for full health, dead face for low health etc). Is it possible to get that actor to access the heath attribute for another actor? Because I didn't use a game attribute for it, and it's gone too far for me to switch either.

Weasel8778

  • Posts: 236
Alright, thanks.
I got it to work.

Another question though:
For another game.
I made an actor for the health that displays different animations (ex. smiling face for full health, dead face for low health etc). Is it possible to get that actor to access the heath attribute for another actor? Because I didn't use a game attribute for it, and it's gone too far for me to switch either.

Make a behaviour for the player which monitors the heath attribute with the block:

For Self, get -attribute- for behaviour -behaviour-

and according to the value of that attribute, creates an actor (in the desired position). Then use the 'switch animation to ... for last created actor' block and change it to the correct one.