How do I create a player health bar?

Get help using Construct 2

Post » Thu Dec 20, 2012 9:46 pm

I really need help with making my player's health bar all on the same x-axis, the same size, and all the same image without having to do everything over again. I want to swap out the placement squares with 8-bit hearts but I couldn't find one with a clear background. Anyways, I want them to be on the same x-axis and to be the same size and distance apart. How can I do this without making a mess of everything?
B
6
Posts: 90
Reputation: 690

Post » Thu Dec 20, 2012 10:25 pm

You could just copy paste the X value of each sprite. But I am guessing you would want to do it dynamically?

If so, it's best to use a placeholder that will cover the whole length of your health bar (it can be hidden at run time). Then you merely take the width of it and divide it by the number of health heart you want, then it will be the same distance
B
27
S
9
G
5
Posts: 108
Reputation: 5,744

Post » Thu Dec 20, 2012 10:38 pm

[QUOTE=Yung] You could just copy paste the X value of each sprite. But I am guessing you would want to do it dynamically?

If so, it's best to use a placeholder that will cover the whole length of your health bar (it can be hidden at run time). Then you merely take the width of it and divide it by the number of health heart you want, then it will be the same distance
[/QUOTE] That would actually be perfect; and a smaller event sheet. I'm not sure how to do that though... I'll tamper with that.
B
6
Posts: 90
Reputation: 690

Post » Thu Dec 20, 2012 10:43 pm

[QUOTE=Yung] You could just copy paste the X value of each sprite. But I am guessing you would want to do it dynamically?

If so, it's best to use a placeholder that will cover the whole length of your health bar (it can be hidden at run time). Then you merely take the width of it and divide it by the number of health heart you want, then it will be the same distance
[/QUOTE] Also, the problem with copying the X is that all of the placeholder squares were made individually, so all their origins are different. So they would not be on the same position unless all of their origins are the same which I don't know how to do without deleting all of them.
B
6
Posts: 90
Reputation: 690

Post » Thu Dec 20, 2012 10:50 pm

You can just double click the sprite individually and change their origin in the image editor. It's the one on the bottom left of the editor, that looked like a crosshair.
B
27
S
9
G
5
Posts: 108
Reputation: 5,744

Post » Thu Dec 20, 2012 10:53 pm

okay, I suggest you to crop a hearth and use a TiledBackground.
Let's say you will use a 25px by 25px hearth(2 transparent px on each side in order to establish a margin) and your player will strat with 3 lifes.

so you will set the bar: width = 25 * [number of lifes]
B
15
S
3
G
2
Posts: 42
Reputation: 2,412

Post » Thu Dec 20, 2012 10:57 pm

if it's needed, you will have to move the health bar in the opposide direction, sprite_name.X - [hearth width]
B
15
S
3
G
2
Posts: 42
Reputation: 2,412

Post » Thu Dec 20, 2012 11:06 pm

Not sure I understand, but check my tutorial here, you can download it to see how it is done: http://www.scirra.com/arcade/example/320/zelda-style-lifebar7Soul2012-12-20 23:06:15
B
83
S
21
G
15
Posts: 1,039
Reputation: 15,134

Post » Fri Dec 21, 2012 11:35 pm

I'm still not really understanding how to do this. I was thinking a bar of 8 slits, like semi-thick lines that are on a slant. They aren't laying on each-other but very close.
B
6
Posts: 90
Reputation: 690


Return to How do I....?

Who is online

Users browsing this forum: jfcservices, selaus and 0 guests