Health Bar issues

Get help using Construct 2

Post » Sun Sep 22, 2013 10:44 pm

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...
Image
B
35
S
17
G
9
Posts: 103
Reputation: 8,131

Post » Mon Sep 23, 2013 12:30 am

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.
B
46
S
16
G
74
Posts: 2,089
Reputation: 44,187

Post » Mon Sep 23, 2013 10:29 pm

@plinkie...

Do you have a link for said Health bar issue? Sorry it took so long to reply...
Image
B
35
S
17
G
9
Posts: 103
Reputation: 8,131

Post » Mon Sep 23, 2013 10:52 pm

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


B
9
S
2
Posts: 35
Reputation: 668

Post » Mon Sep 23, 2013 11:16 pm

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)
B
84
S
22
G
15
Posts: 1,039
Reputation: 15,249

Post » Tue Sep 24, 2013 12:12 am

Nice examples @WhiteX @7Soul! Will look into ASAP!!! Much appreciated!
Image
B
35
S
17
G
9
Posts: 103
Reputation: 8,131

Post » Wed Sep 25, 2013 5:04 pm

@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)?
Image
B
35
S
17
G
9
Posts: 103
Reputation: 8,131

Post » Wed Sep 25, 2013 6:34 pm

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. :)
B
9
S
2
Posts: 35
Reputation: 668

Post » Wed Sep 25, 2013 6:35 pm

Oh, every tick should be on all last 3
B
9
S
2
Posts: 35
Reputation: 668

Post » Wed Sep 25, 2013 8:02 pm

Oh....Ok let me try that dude... I haven't tried the "every tick" condition on all... Hopefully that solves the issue...
Image
B
35
S
17
G
9
Posts: 103
Reputation: 8,131

Next

Return to How do I....?

Who is online

Users browsing this forum: Baidu [Spider], jorgmaquoi, SignalOne and 18 guests