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: 14
Reputation: 407

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
40
S
22
G
81
Posts: 297
Reputation: 44,735

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
47
S
17
G
81
Posts: 2,223
Reputation: 48,093

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: 209
Reputation: 3,476

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: 14
Reputation: 407


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 27 guests