0 Favourites

Health Bar issues

  • Hello C2 Community! Got another one for you guys... I don't think this one is as difficult as my last post(s) so hopefully you guys can chime in... I have a platformer going, and now I at the stage where it's time to get the HUD assets some "meaning"... I've been through Ashley's tutorial on platform games like back and forward again for a week now, and my issue is this: Instead of a C2 editor sprite. I substituted it with one of my own art asset... So I imported the animation frames(one for full health, half and empty) And got the instance variable thing going... Made my max health at 50, and the first enemy collision nets 25 pts. damage to hero's health... Ok that works no problem... Even figured out how to change the graphic for the health bar from full to half... No the problem is I want to get to empty and lost of life on the final collision with enemy... Is there a simple way of performing this task folks? Appreciate any help...

  • Change health bar from full to empty.

    Go to Game Over/ Game restart screen on another layout.

    Respawn player at a checkpoint.

    Depends how your game works.

  • plinkie...

    Do you have a link for said Health bar issue? Sorry it took so long to reply...

  • On start of the layout

    set global variable "playaLife" to 50

    Playa on collision with enemy

    subtract 25 from "Playalife"

    system - compare variable

    if playalife > 49 healthbar set animation to full

    if playalife = 25 healthbar set animation to half

    if playalife < 1 healthbar set animation to empty

    ---playa - destroy

    syntax is not correct, i am at work, the values are to be on the safe side

  • I have a health bar example on the arcade, it might help you http://www.scirra.com/arcade/example/5456/circular-life-bar-example (remember you can download the .capx)

  • Nice examples WhiteX 7Soul! Will look into ASAP!!! Much appreciated!

  • WhiteX

    Dude! I finally figured out how to install the global variable, and now I need to know how to install the G.V. to my player/sprite... When I run the game, my HUD health bar doesn't change to the corresponding animation frames... Do I need to add a variable for the enemy's attack as well as my protagonist "being attacked"(or receiving damage)?

  • well, on the start of the layout it is set to 50 and the corresponding animations are set as animations on a single sprite element, right?

    OK

    Playa on collision with enemy

    subtract 25 from "Playalife"

    This will make the playalife lose 25 points if the player is in collision with an enemy.

    These next 3 events check the status and set the animation

    system - compare variable

    if playalife > 49 healthbar set animation to full

    system - compare variable

    if playalife = 25 healthbar set animation to half

    system every tick - compare variable

    if playalife < 1 healthbar set animation to empty

    ---playa - destroy

    Sorry aboy my syntax earlier. :)

  • Oh, every tick should be on all last 3

  • Oh....Ok let me try that dude... I haven't tried the "every tick" condition on all... Hopefully that solves the issue...

  • One other question dude... WhiteX, Am I subtracting from Global or instance variable(s)? I have an instance health variable on my player on the properties page... I also created a global variable on the event sheet... Which one am I suppose to use? the global variable doesn't seem to be subtracting from my "player's" health at all... The instance one works somewhat, but I can't figure out how to get the final health bar animation to work to indicate that the event is working with the instance variable... I hope this makes sense...

  • OK!!!!! NICE!!! It worked dude! Thanks again WhiteX!!! Just had every thing in the wrong places lol!!! The event sheet is super sensitive... Everything has to be in the correct order or it won't run right... Well appreciate it! I may have to send you a PM concerning "how to make my player die" <img src="smileys/smiley32.gif" border="0" align="middle" />

  • i use global variable for the main player�s health because if i have to destroy it to make way for another graphic that still is the controllable avatar, like, getting in a car, transforming, it�s health is stored outside it�s instance.

    To make it "die" is the last part, system - every tick - compare variable

    playalife < 1

    playa - destroy

    once hit twice, it will vanish

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Sweet!!! Awesome dude... Thanks for all the help WhiteX!!!

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