How do I make an imagelike health bar [solved]

0 favourites
  • 6 posts
From the Asset Store
Custom animated Health Bar - check youtube video to make it yourself
  • Hello.

    So I am trying to make a health bar Zelda like, with hearts or whatever image you like.

    Lets say you have 3 hearths and whenever you get hit you lose 1, and when you lose all 3 you die. Alright so I found this tutorial but I can't seem to put it to use to such a thing:I don't really care for the buttons, I guess that's the way to explain how it works but can't seem to apply it to an actual game and I do believe it has to be easier to do so.

    I've set the hearths, but I don't know how to exactly make the hearts become the global variable for health points. I suppose I have to do something like whenever you lose 1 hp withdraw 1 heart, but can't seem to get it right.

    Anyone has some experience with this matter would be appreciated.

    Thanks!

  • I made a game with this kind of health bar, it is very simple (don't be scared by the length, it is very detailed) :

    • create a "heart" sprite
    • create a specific layer to put the "health bar" (can be skipped)
    • create an event at the start of layout (or at the start of your game) :

    repeat 3 times :

    create heart on layer "health bar" in (50+50*loopindex() , 50)

    this create the hearts in (50,50) ; (100,50) ; (150,50)

    the values "50" can be replaced if you want to place your hearts at a different position.

    • add a condition to the event where the player lose a life, you must already have created :

    heart : pick nearest to (720, 0)

    this pick the heart at left (even if there is more or less hearts)

    You can also change the value "720"

    • add a sub-condition to this event :

    compare 2 values : heart.count > 0

    • and the action corresponding :

    heart : destroy

    • you can add a "Else" condition : that means the player lose, there is no heart left.

    in few words:

    repeat 3 times : create heart on layer "health bar" in (50+50*loopindex() , 50)

    heart : pick nearest to (720, 0)

    • if heart.count > 0 : destroy heart
    • else : player lose
  • [edit] is it me or you just have removed your message?

    yes, it should work

    I think the detection polygons aren't well defined, or the collisions are maybe deactivated.

    you can try the condition: "Player is overlapping X"

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yeah I deleted it because I made it to work. probably what you're saying was the problem I tried with every X seconds and it worked just fine.

    I think this way is easier for me but thank you very much for your help, might come handy in the future!

    Cheers

  • you're welcome!

    There is often many ways to do something, I just suggested one way, certainly not the best. In that case, your way is effectively better, I think.

    don't forget to edit your first post and add [solved]

  • Cheers buddy, you're awesome!

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