Scale by number

Get help using Construct 2

Post » Mon Jan 30, 2012 11:40 pm

I'm planning on making a simple health bar that changes scale according to player's health. How can I make it to be at full length when player's health is 100 and completely invisible at 0? Also it should update smoothly, so some lerp(?) stuff should be there too. I'm really at loss with the expressions and whatnot.

Thanks in advance.
B
15
S
5
G
4
Posts: 214
Reputation: 3,124

Post » Tue Jan 31, 2012 12:03 am

If for example full length is 200 then just always set the length to this:
200 * health/100

Or change 200 to whatever you want the max length to be.
B
79
S
24
G
54
Posts: 4,751
Reputation: 40,765

Post » Tue Jan 31, 2012 12:19 am

I usually create a healthbar sprite...

Then add a varaible.
Healthbar = 100

Then in events something like this.

This set the healthbar sprite with to the Healthbar Variable which is 100, Using EveryTick to check this all the time.

EveryTick
Healthbar Sprite width = Healthbar


Then the next bit deducts 1 from the heathbar variable when ever you collide with an enemy, Which in turn makes the Healthbar Graphic/Sprite Smaller.

PlayerSprite OnCollision with EnemySprite
Healthbar = Healthbar -1
B
40
S
14
G
11
Posts: 243
Reputation: 9,432


Return to How do I....?

Who is online

Users browsing this forum: grigrizljac, GSquadron and 22 guests