adding a health bar

0 favourites
  • 9 posts
From the Asset Store
Customize the animation of character when item changed
  • hey guys ,

    was wondering what to do to insert a health bar ,

    so far I can only add a global variable then get the system to subtract from that number ....

    i think a health bar looks a lot better .

    can anybody suggest how to or

    where to find the answer ?

    thanx a lot >

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hey Carminie, I am new here but i have been programming for a few years. My suggestion is make a health bar image that has a set of animations that each are at a different point in the health bar. Then when you lose heath or gain health you can set the animation to a different frame. With this you can also incorporate an instance variable that represents the amount of health you have.

    [|||||||||]- first frame

    [|||||||| ] - second frame

    [||||||   ] - third frame

    ..... - other frames

    [        ] - empty health (dead)

    there may be a better way or even a better way of explaining this.

    sorry if this is not helpful.

  • You can get construct to change the width of a red (or any color you like) square sprite to match the players health.

    I.E an event that every tick "set width to players.health"

    Have a look at the space blaster game demo that's where I got the info from.

    Hope this helps.

  • wow ! thank you for prompt reply guys !

    i ll give it a shot maybe later today , maybe tomorrow

    my g/f thinks i spend to much time "playing" games

    and recording music .

    thank God she s leaving for a week tomorrow

    I m never going to get married !!

    I ll update u guys asap

  • thank God she s leaving for a week tomorrow

    I m never going to get married !!

    This is a good kid right here. <img src="smileys/smiley36.gif" border="0" align="middle" />

  • <img src="smileys/smiley3.gif" border="0" align="middle" />

  • to piggyback of knight007au

    create a small tick -> import tick as a tiled BG

    create a variable for tick -> health

           set a value for health (whatever width you want i.e. 100)

    system -> on start of layout -->

         tick -> set width to tick.health

         tick -> set variable health to tick.health (now the current value     of heath is stored)

    sprite -> on collision -->

         tick -> set width to tick.health - 10 (or however much you want the health bar to be reduced by)

         tick -> set variable health to tick.health

    tick -> health (less than or equal to) tick.width

         sprite -> destroy

    there may be a simpler way, but this 1 is functional

    injoy!

  • thank you very much boys n girls !!

    i haven t had time to try all these nice things out yet

    as it has been a hectic week

    ( yes I broke up with my g/f in the end so

    no i m not going to get married )

    sorry for bringing up personal life stuff in a forum that should only be dedicated to game making I guess

    i ll let you guys know

    a big thank you to everybody for taking your time to help

  • Hey Carminie, I am new here but i have been programming for a few years. My suggestion is make a health bar image that has a set of animations that each are at a different point in the health bar. Then when you lose heath or gain health you can set the animation to a different frame. With this you can also incorporate an instance variable that represents the amount of health you have.

    [|||||||||]- first frame

    [|||||||| ] - second frame

    [||||||   ] - third frame

    ..... - other frames

    [        ] - empty health (dead)

    there may be a better way or even a better way of explaining this.

    sorry if this is not helpful.

    I like this idea. Expanding upon it, I'm wondering to set the full health bar as the sprite. Then set each different health % as a seperate animation.

    Then as the instance variable changes (sprite takes damage) have it call the corresponding animation.

    Example:

    health(instance variable)= 10 then set health (sprite) animation to 100percent

    health = 6 then set animation to 60percent

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