Life bar issue...

0 favourites
  • 6 posts
From the Asset Store
Health, Weapon & Rage Bars for your Games. Easy to use & Customize.
  • Greetings everyone. I set up a life bar for my main hero awhile ago, and it has been draining fine until I decided that I wanted it to regenerate 1 health per a certain amount of points earned. My event looks like this:

    Event condition(<system> <compare variable> "score" greater than or equal to 25)

    Action(<Hero> <add to> instance variable "Life" +1)

    My hero has a max life of 5 chunks in the bar that he starts out with, but when he hits 25+ score and the above event activates the health line inside the health bar frame grows and shoots across the entire top of my screen! I can then get hit as many times as I want because of the ever growing health bar... Am I doing something wrong? I have my health bar set up just like Kiyoshi's guide showed in the tutorials section of scirra.com with my own graphics of course. Link: Kiyoshi's Life bar guide. Can anyone explain why something like that would happen just to add a single chunk back onto my health? Thanks in advance! <img src="smileys/smiley1.gif" border="0" align="middle">

  • It's because the condition is always true, the score is over 25 once it hits 25, and it's adding to the health constantly, I think you need a trigger once condition, at least...

  • looking at this again you will need to rethink your events...

    you need to give your healthbar a variable, or a global variable if you prefer, lets call it regen, then when regeneration is possible trigger:...

    set "regen" to score

    score => regen + 25...        add 1 to health

    Trigger once                  set "regen" to score

    So every time your score is 25 over the last health top up it will add another and re start the "regen" counter...

  • Hey Pixel perfick, thanks for the response! I'm using triggers now and it only goes up 1 health chunk at a time yay. But now if my health is full and I have not taken any hits by the time I hit the set score the health bar with grow 1 piece more than my max health each time conditions are met. Is there a quick event or something I could add that would not let it grow beyond 5? Thanks much for any feedback! <img src="smileys/smiley1.gif" border="0" align="middle" />

  • Nevermind I got it. <img src="smileys/smiley36.gif" border="0" align="middle" /> Thanks for all the help!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Sorry for delayed response, glad you got it figured...

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