Health bar on top of player/enemies

For questions about using Classic.

Post » Sun Nov 21, 2010 7:56 pm

I have picked up on my game again and I want to know how to make the player have his health bar on top of his head similar to many rts games out there and also for the enemies which take some hits have their own health bar.

Any idea how to make it so that the bar floats on the player and enemies/whatever else with health?

and also change size depending on player/enemy health which I have no clue on how to do.

Thanks in advance.
B
9
S
2
G
3
Posts: 176
Reputation: 1,954

Post » Sun Nov 21, 2010 8:11 pm

What to do:

Make an image point above said enemy or player and say:
SYSTEM:always>Healthbar>set position to object>Player>image point 1.
>Healthbar>Set width=Player('health')



Here is a cap I did it in.

http://dl.dropbox.com/u/7605789/HOPEthisHELPS.cap

[u:2j3fpmzl]Touch the spikes to see how he loses health.[/u:2j3fpmzl]
B
2
G
2
Posts: 30
Reputation: 710

Post » Sun Nov 21, 2010 8:19 pm

Even easier, set the x position to player.x-(desired width of bar/2) and the y to player.top-some amount.
Moderator
B
87
S
32
G
33
Posts: 3,005
Reputation: 27,397

Post » Sun Nov 21, 2010 8:32 pm

Thanks guy's, both of you, however I wonder what the / actually is supposed to do? either way thanks for helping me out.
B
9
S
2
G
3
Posts: 176
Reputation: 1,954

Post » Sun Nov 21, 2010 10:29 pm

[quote="LavaWave":31bgri2g]Thanks guy's, both of you, however I wonder what the / actually is supposed to do?[/quote:31bgri2g]

You mean the one in my post? It's division.
Moderator
B
87
S
32
G
33
Posts: 3,005
Reputation: 27,397

Post » Mon Nov 22, 2010 12:21 am

Containers work beautifully with this.
[url:2jzvjudu]http://sourceforge.net/apps/mediawiki/construct/index.php?title=Containers[/url:2jzvjudu]
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Mon Nov 22, 2010 6:47 am

[quote="Arima":147isxbu][quote="LavaWave":147isxbu]Thanks guy's, both of you, however I wonder what the / actually is supposed to do?[/quote:147isxbu]

You mean the one in my post? It's division.[/quote:147isxbu]

My chars health position is X-50 and Y-120 yet it looks fine, I wonder why should I put the division sign for, either way it works so far, atleast for the player, I haven't put enemies with health yet but I will work that out later.
B
9
S
2
G
3
Posts: 176
Reputation: 1,954

Post » Mon Nov 22, 2010 2:49 pm

Because of this part:

[quote="LavaWave":3cupgr97]and also change size depending on player/enemy health which I have no clue on how to do.[/quote:3cupgr97]

This way it will automatically adjust its x position for the length of the bar.
Moderator
B
87
S
32
G
33
Posts: 3,005
Reputation: 27,397


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests