How do I Set HealthBarFX

Get help using Construct 2

Post » Thu Aug 04, 2016 3:48 pm

how to set value HealthBarFX from Player.HP per %

if my Player.HP = 400 set Value HealthBarFX @#!@? what math need
i cant find post about setup HealhBarFX

link post or Capx are welcome <3
B
15
S
7
G
7
Posts: 201
Reputation: 5,277

Post » Thu Aug 04, 2016 4:54 pm

HealthBarFX > Set width to Player.HP*.25

You need to find the right number to multiply against (*.25) versus 100% of the HealthBarFX size, which depends on the amount Player.HP.

In the above example (*.25) is 25% of the Value. You have to play with the values but, multiplying times a decimal value is how you obtain or set by percentage.
Image
B
75
S
23
G
3
Posts: 673
Reputation: 9,273

Post » Thu Aug 04, 2016 6:28 pm

@TheDom can you make example with capx please ? :) <3

my player hp change all time

and i dont have only one player is multiplay with defernce value HP
B
15
S
7
G
7
Posts: 201
Reputation: 5,277

Post » Thu Aug 04, 2016 9:26 pm

if you want set hpbarfx to Player.hp
you should add to player container this hpbar
(you find container in sprite properties)

set width to: (hp/hpmax)*220 (220 this is pixel width)
when hp is full, your bar will have 220 px width
when hp i 1/2 your hpbar width will be 110

if you have only one variable 'HP'
set width to HP
(but when your hp will be 9999 your hp bar will have 9999px
so you can always add '/2' after set width to HP/2
B
109
S
25
G
43
Posts: 1,883
Reputation: 33,553

Post » Thu Aug 04, 2016 11:32 pm

@delgado ok nice

but this trick with width he make the bar health longer or smaller

i dont need that!! i want standar width with the HPBar..

if some one have 450.000 HP tha hpbar gonna run out of layer? i dont think this is best way
B
15
S
7
G
7
Posts: 201
Reputation: 5,277

Post » Thu Aug 04, 2016 11:49 pm

ok here is your lucky day
https://www.dropbox.com/s/kvlw55q55wbt3 ... .capx?dl=0

me and my friend made this hp bar
from green to red
using it in the game im curently developing
http://kiugetski.com/space

this hp bar work with any life value :D using 2 varriables HP and MAXHP
B
27
S
9
G
3
Posts: 136
Reputation: 3,750

Post » Fri Aug 05, 2016 12:10 am

@kiugetski you are amazing <3

thank you very much, that's exactly i'm looking
B
15
S
7
G
7
Posts: 201
Reputation: 5,277

Post » Fri Aug 05, 2016 1:36 am

glad to have helped you out :D
B
27
S
9
G
3
Posts: 136
Reputation: 3,750

Post » Sat Nov 26, 2016 12:13 am

Thx this helped a lot
B
11
S
2
G
1
Posts: 34
Reputation: 722

Post » Sat Nov 26, 2016 8:49 pm

kiugetski, excellent method with the variables, a really nice share, Thanks. ;)

btw best of luck with your project.
B
12
S
3
G
2
Posts: 38
Reputation: 1,380


Return to How do I....?

Who is online

Users browsing this forum: blissfulwizard, DevinMurray and 15 guests