Energy bar

Get help using Construct 2

Post » Mon Mar 05, 2012 11:13 pm

Hello to all, i would like to know, for my ennemies in all the level, how i can add an energy bar??
When the player hit an annemy he have to hit him somes times before the ennemy die.
I would like to have this kind of stuff for all the ennemies.
B
32
S
9
G
6
Posts: 1,470
Reputation: 7,957

Post » Tue Mar 06, 2012 2:03 am

Well the basic health bar concept is to adjust an object's width based on a variable. Perhaps when an enemy is hit, you could create an energy bar at that enemy's position. Maybe it could have fade behavior with fade in and fade out?
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Tue Mar 06, 2012 2:09 am

yes this is what i want, an energy bar who appears when the ennemy is hit :D but i dont know how to do that
B
32
S
9
G
6
Posts: 1,470
Reputation: 7,957

Post » Tue Mar 06, 2012 7:33 am

This may or may not work, (I don't know too much about this)

Step 1. Add a sprite that looks like a health bar.
Step 2. Set up a variable named "Enemy Health" (or something) and set the number to whatever you want say 5 (so 5 hits and the enemy dies)
Step 3. Assign the variable to your enemy sprite.
Step 4. Go to your event sheet and select "System", select "Subtract from variable" (or whatever says subtract). Select the variable as "Enemy Health" and the number as 1.
Step 5. Select the health bar sprite and add a fade behavior.


Not sure how to do it but somehow you can assign it so it fades 1 every hit till it goes away completely after 5.
B
8
S
4
G
3
Posts: 69
Reputation: 2,556

Post » Tue Mar 06, 2012 8:05 am

The trick is not to "fade" but to change the length of the sprite by either altering width or height
B
42
S
19
G
12
Posts: 723
Reputation: 13,911

Post » Tue Mar 06, 2012 2:48 pm

I've made a simple test:

http://labgames.camo.com.br/enemies_hp
http://labgames.camo.com.br/enemies_hp/enemies_hp.capx

You need to improve the handle of the bar within more enemies on screen and put the origin point on left, if your bar sprite will have a border to have the "fill" effect...

I'm still not used on how to add event like "On <object> created" and how to handle instances properly, otherwise i would have made a more complex example hehe.Cassianno2012-03-06 14:49:54
English is not my native language. Sorry for any mistakes and feel free to correct me if needed.
B
14
S
5
G
3
Posts: 110
Reputation: 3,225

Post » Tue Mar 27, 2012 1:51 pm

@Cassianno the capx is not working
B
303
S
6
G
5
Posts: 163
Reputation: 12,152

Post » Tue Mar 27, 2012 2:02 pm

This seems interesting.
@Cassiano: could you provide us a working .capx? Thank you!
B
15
S
5
G
1
Posts: 40
Reputation: 2,026


Return to How do I....?

Who is online

Users browsing this forum: Justin1967, qaisarehman, Yahoo [Bot] and 31 guests