Creating a Health Bar using heart pieces

Get help using Construct 2

Post » Sun Dec 01, 2013 11:04 am

Hello Construct 2 community,

For the past few weeks I have been taking my time to learn how to use C2 using Ashley's how to make a platform game tutorial and many others. So far, it's going great!

However, I was unable to find out how to make a working health bar using my image I created. I couldn't really find a thread that explained how to code a Health Bar this way. I tried making actions when an enemy hit the player to frame 1, in which one heart piece is missing, but then I didn't find out how to make sure it goes to frame 2 where there are no heart pieces available. Another problem I have is that it doesn't stay on-screen as I want it to. I can't figure out how I can make stay on the same position while not being affected by the actual gameplay. This leads me to conclude, that I may have done everything wrong since the first step and I would appreciate it if you guys could help me out, and explain how you guys are doing this.

Here are the images I created:




B
8
Posts: 7
Reputation: 378

Post » Sun Dec 01, 2013 11:09 am

I would set up HEALTH global variable and when HEALTH = 2, show Frame 1, HEALTH = 1, show Frame 2, HEALTH = 0, show Frame 3 etc. This way you can subtract values from HEALTH when an enemy hits the player so it updates.

To keep the health on screen scrolling with the player you need to put it on it's own layer and set the Parallax to 0,0 (under layer properties).
B
46
S
16
G
73
Posts: 2,084
Reputation: 43,677

Post » Sun Dec 01, 2013 11:38 am

Create a sprite (I named this how HealthSprite) and add these 3 images in it as frames.

frame 0


frame 1


frame 2



Now, create a Global Variable called HP and put 2 as a value of this variable.

Put one condition, everytick set HealthSprite Frame to HP
In the condition you can make subtracting or adding values to the variable and the player HP.gillenew2013-12-01 11:40:05
Open for Commission, contact email > [email protected]



my personal website with news in my game developer adventure! |

adult ( 18) pixel art games
B
134
S
24
G
21
Posts: 513
Reputation: 24,939


Return to How do I....?

Who is online

Users browsing this forum: fearfulelephants and 17 guests