Creating a Health Bar using heart pieces

0 favourites
  • 3 posts
From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin
  • 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:

    <img src="http://img833.imageshack.us/img833/4963/bce9.png" border="0" />

    <img src="http://img7.imageshack.us/img7/1379/fy60.png" border="0" />

    <img src="http://img28.imageshack.us/img28/4691/4tnh.png" border="0" />

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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).

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

    frame 0

    <img src="http://img28.imageshack.us/img28/4691/4tnh.png" border="0" />

    frame 1

    <img src="http://img7.imageshack.us/img7/1379/fy60.png" border="0" />

    frame 2

    <img src="http://img833.imageshack.us/img833/4963/bce9.png" border="0" />

    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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)