How do you do HP bars?

For questions about using Classic.

Post » Wed Oct 28, 2009 9:54 am

I'm currently confused on how to make HP/MP/Etc Bars similar to fighting games. Like for example, when an enemy hits the player, the HP bar will slowly resize to its designated point. In other words, if I have a bar at 100%, and an enemy hits me, which decreases my HP to 80%, the HP bar should slowly resize until the 100% bar arrives at 80%.

Unlike in the platform school where HP is changed using different animation frames of the Heart Image, I'm not sure if I can use that principle in this one. Help anyone? Thanks in advance!
B
10
S
5
G
8
Posts: 203
Reputation: 4,395

Post » Wed Oct 28, 2009 10:27 am

Easiest right now is resizing an image based on percent. If you make an image that's 200x32 (200 being width) you can do this, using a variable "HealthVariable" who's max value is 1000:

Set width to ===> Bar.OriginalWidth*(HealthVariable/1000)

That will set the width based on what percentage between 0 and 1000 HealthVariable is. To make it regenerate, just add to HealthVariable.
B
5
S
2
G
3
Posts: 234
Reputation: 1,818

Post » Wed Oct 28, 2009 10:27 am

I quickly made a little example for you: Download
:)
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445

Post » Wed Oct 28, 2009 10:29 am

Pfft, my way is better, no need for a fixed original width. :D
B
5
S
2
G
3
Posts: 234
Reputation: 1,818

Post » Wed Oct 28, 2009 10:35 am

[quote="konjak":1gs34fmg]Pfft, my way is better, no need for a fixed original width. :D[/quote:1gs34fmg]

Your talking about the Maxwidth value of the healthbar? :?
Just set it on start of layout to the width, so you don't have to reenter the value if you change it in the layout.

And how exactly does your example help with the bar slowly resizing? :P
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445

Post » Wed Oct 28, 2009 10:47 am

Yey! Thanks for the help guys, that was quick. Amazing!!
B
10
S
5
G
8
Posts: 203
Reputation: 4,395

Post » Wed Oct 28, 2009 10:58 am

[quote="PixelRebirth":1savw98k]And how exactly does your example help with the bar slowly resizing? :P[/quote:1savw98k]

Just add to your health variable. When you want it to not be greater than 1000 just have an event to say to stop it from being that.

I'm sure both our techniques are fine, I was kidding, man. I guess I missed that it would gradually change instead of regenerate.
B
5
S
2
G
3
Posts: 234
Reputation: 1,818

Post » Wed Oct 28, 2009 11:04 am

Don't forget about the line object, the gradient object, the tiled bg object, the box object.......
Image Image
B
161
S
48
G
91
Posts: 7,359
Reputation: 67,273

Post » Wed Oct 28, 2009 11:05 am

[quote="konjak":3i1aeoan]I'm sure both our techniques are fine, I was kidding, man.[/quote:3i1aeoan]

It didn't strike me as dead serious, due to the amount of smilies used. :wink: There's one again.
Still why did you reply faster than I did? Don't do that again! :mrgreen:

[quote="TheJanMan":3i1aeoan]Yey! Thanks for the help guys, that was quick. Amazing!![/quote:3i1aeoan]

No prob. As long as the questions are simple enough for my brain, I will always try to help out, hehe. And many other users do the same thing. You did know this community rocked? :)

[quote="newt":3i1aeoan]Don't forget about the line object, the gradient object, the tiled bg object, the box object.......[/quote:3i1aeoan]

Indeed. Wasn't there something in the Uploads section with many different healthbar examples?
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445

Post » Wed Oct 28, 2009 11:16 am

Hmm yeah this community rocks. :shock:
B
10
S
5
G
8
Posts: 203
Reputation: 4,395

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests