How do I create a player health bar?

0 favourites
  • 9 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • 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?

  • 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

  • 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

    That would actually be perfect; and a smaller event sheet. I'm not sure how to do that though... I'll tamper with that.

  • 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

    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.

  • 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.

  • Try Construct 3

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

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

  • if it's needed, you will have to move the health bar in the opposide direction, sprite_name.X - [hearth width]

  • 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-lifebar

  • 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.

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