healbar %

Get help using Construct 2

Post » Mon May 19, 2014 6:28 pm

I have a health bar at 20 pixels width(max) and variable healthpoints of 100(max)

if i want it the healthpoints variable to take 25 off how would i translate that to represent the width of the healthbar?
B
14
S
6
G
3
Posts: 83
Reputation: 4,228

Post » Mon May 19, 2014 6:52 pm

First apply the damages to the health, then set the healthbar width to 20*( healthpoints/100)
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Post » Tue May 20, 2014 12:31 am

Remember that if you use sprite for the health bar, with the given method this will scale the sprite.
If you want it to be shortened/lengthened then use Tiled background for it.
In Tiled background properties you can find "hotspot", this defines how the object width is changed, experiment with it to see how it works.
B
6
G
1
Posts: 28
Reputation: 458

Post » Tue May 20, 2014 2:15 pm

Thanks guys,

@Aphrodite, your method worked but i work it out a different way b4 your reply which is:

set width to enemychuchugreen.health/5

since full bar is 20 pixels and health points is 100 the division is 5 therefore nomatter what value the healtpoints value is it sets the pixels width to that shared by 5 :). So its a bit more simpler to understand the math :)
B
14
S
6
G
3
Posts: 83
Reputation: 4,228


Return to How do I....?

Who is online

Users browsing this forum: amazingdream, Yahoo [Bot] and 20 guests