How do I Create a 20/20 Health Bar

Get help using Construct 2

Post » Wed Mar 25, 2015 10:42 pm

My game needs a HP Ratio like 20/20 is full health, 10/20 is half etc. i would like to minimize the use of text boxes and global variables as much as possible, im also wondering if theirs a way to do it with just one text box and one global variable. Thanks for your time guys!
B
6
S
1
Posts: 17
Reputation: 391

Post » Wed Mar 25, 2015 11:03 pm

Do you want to show the health bar or just text?

Healthbar
If you want your max health bar to be eg 250px
Your on top health bar should be 250 / 20 * amount of current hp.
So 5hp will be 62.5px wide to show the hp

Text
Global variable = current hp
Set text to "current hp" & "/20"
B
32
S
7
G
2
Posts: 317
Reputation: 2,851

Post » Wed Mar 25, 2015 11:06 pm

sqaure image object
variables
sqaure.maxhealth
square.currenthealth

*total bar width when full = 100 pix

set square width to (100 * (sqaure.currenthealth / square.maxhealth))
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,572

Post » Thu Mar 26, 2015 1:55 am

Not a bar sorry, just the text. with every level i would like to add an increase for the capacity
B
6
S
1
Posts: 17
Reputation: 391

Post » Thu Mar 26, 2015 2:34 am

If you want the max hp to change with level, you need either a well defined function or another variable for it. eg.
Code: Select all
Set text to HP & "/" & MaxHP

If you don't want to use another variable, use something like
Code: Select all
Set text to HP & "/" & (15 + 5 * Level)
, which is of course more limited.
B
14
S
5
G
1
Posts: 189
Reputation: 1,536


Return to How do I....?

Who is online

Users browsing this forum: irina, UberLou and 12 guests