How do I Make a Health Bar Go Down Normally?

Get help using Construct 2

Post » Wed Jul 19, 2017 8:53 pm

Sorry if this question was asked already, but I haven't found one that answered this.

How do you make a health bar (horizontal or vertical) decrease in length from max length to 0? I'm trying to make a platformer game of some sort, and it requires a health bars for the player and enemies. Every time I make a health bar lose value (or "health"), it loses its length on BOTH sides of the bar, meaning it looks odd when the entity it is for loses health. I want ONLY the top (for vertical) or the left (for horizontal) side of the bar to shorten until the bar depletes. Plus, it should work for bars that have different colors for design, or bars that have outlines without making them look stretched. I've been stuck at this for a while now, and I can't figure out how to solve this.

Thanks in advance!
B
7
S
1
Posts: 12
Reputation: 403

Post » Wed Jul 19, 2017 9:14 pm

@ezgaming420


They are many ways to do it, here are some ideas to help you started, I hope it helps

https://www.dropbox.com/s/jeq49flgj1wrq1w/Create%20Healh%20bars%20to%20multyple%20instances2.capx?dl=0
B
38
S
22
G
60
Posts: 222
Reputation: 34,032

Post » Wed Jul 19, 2017 9:15 pm

It's because it sets the size and centres the object on its origin. There are many ways to do it, you could resolve it by moving the origin image point to the side of the bar that should remain where it is, then you'll see the size decreasing from the other side. That's how I've done it in the past.
B
46
S
16
G
73
Posts: 2,084
Reputation: 43,677

Post » Wed Jul 19, 2017 9:48 pm

Yes, if you want the bar to only lose health from one side, set the origin point of the sprite to be at the opposite end and then set the object's width (for horizontal bars) or height (for vertical) to decrease in line with the health variable.
Image



Coming soon on Steam!
B
16
S
9
G
3
Posts: 204
Reputation: 3,466

Post » Wed Jul 19, 2017 10:02 pm

Thanks everyone! I didn't know before that the origin point affects that :? I'm still trying to learn everything in Construct 2.
B
7
S
1
Posts: 12
Reputation: 403


Return to How do I....?

Who is online

Users browsing this forum: Lancifer, Nicolas951, Shenkai the ssj and 24 guests