life bar help

For questions about using Classic.

Post » Fri Apr 01, 2011 6:35 pm

Okay searched the forums and I cannot find how to make life bars. I want to make a 4 heart life bar, every time the main character gets hit he loses a life...Please help :(
B
1
G
1
Posts: 7
Reputation: 464

Post » Fri Apr 01, 2011 7:10 pm

This is done very easiliy, actually. Using Animation frames.

The goal is to have the Animation Frame equal to how much health you have.

The events:

->Always
+Healthbar.Frame = Player.Value('health')

That's about it... :)
B
26
S
7
G
5
Posts: 202
Reputation: 5,235

Post » Fri Apr 01, 2011 8:39 pm

or
Always
heart.destroy

For 0 to global('life')
system, create object "heart" at global('lifebarx')+((heart.width+5)*loopindex)

that doesn't need multiple frames
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Fri Apr 01, 2011 11:33 pm

Using a single heart that's square in dimensions loaded to the tiled background object, and scaled to 4 times its original width.
For example if the heart was 32x 32 scaled to 128x 32

On damage received
heart set width to heart.width- 32
Image Image
B
161
S
48
G
89
Posts: 7,347
Reputation: 66,249

Post » Fri Jun 14, 2013 1:08 am

[QUOTE=newt] Using a single heart that's square in dimensions loaded to the tiled background object, and scaled to 4 times its original width.
For example if the heart was 32x 32 scaled to 128x 32

On damage received
heart set width to heart.width- 32[/QUOTE]


Hi is it's a bit old post, but I have a problem.
I've done what you say, to go climbing frame, but what it does is that it makes the cut only smaller, and only does it when you discount the first life to the player, with the other three did not do anything.
Let's see if someone can give me alguan solution, or if there is another way to do it.
B
11
Posts: 26
Reputation: 1,147

Post » Fri Jun 14, 2013 2:32 pm

[QUOTE=newt] Using a single heart that's square in dimensions loaded to the tiled background object, and scaled to 4 times its original width.
For example if the heart was 32x 32 scaled to 128x 32

On damage received
heart set width to heart.width- 32[/QUOTE]

Or you set health variable for the player. Private variable health=4
And on events:

Always
TiledBackround: Set width to Player.Value('health')*32
B
31
S
8
G
3
Posts: 517
Reputation: 5,011

Post » Thu Nov 21, 2013 11:36 pm

Hy guys,
Someone has an example .capx file? I want to create a life bar with 3 hearts. (When player on collision with enemy destroy 1 heart and the same with stars counter, when player on collision a star, system generate a star on counter). Is possibile?

https://dl.dropboxusercontent.com/u/122498815/Scirra%20-%20Construct2/HealtBar.capx

Currently i have this but is not good for me.

Simo2013-11-22 00:13:43
B
12
S
3
Posts: 40
Reputation: 1,304

Post » Fri Nov 22, 2013 11:44 pm

[QUOTE=Simo] Hy guys,
Someone has an example .capx file? I want to create a life bar with 3 hearts. (When player on collision with enemy destroy 1 heart and the same with stars counter, when player on collision a star, system generate a star on counter). Is possibile?

https://dl.dropboxusercontent.com/u/122498815/Scirra%20-%20Construct2/HealtBar.capx

Currently i have this but is not good for me.

[/QUOTE]

B
12
S
3
Posts: 40
Reputation: 1,304

Post » Sun Nov 24, 2013 4:21 am

[QUOTE=Simo]
[/QUOTE]

Hey, you've only just asked your question a day before you bumped the request. We can only reply as quickly as we have (free) time to make examples.

However, I will try and make you one soon and upload it for you. In the mean time you could dig around the source code to my game IHadHope as I did something like what you want too I believe: http://ihadhope.blogspot.ca/p/download.htmlJayjay2013-11-24 04:22:02
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009

Post » Mon Nov 25, 2013 10:07 pm

[QUOTE=Jayjay] [QUOTE=Simo]
[/QUOTE]

Hey, you've only just asked your question a day before you bumped the request. We can only reply as quickly as we have (free) time to make examples.

However, I will try and make you one soon and upload it for you. In the mean time you could dig around the source code to my game IHadHope as I did something like what you want too I believe: http://ihadhope.blogspot.ca/p/download.html[/QUOTE]

Thanks, I did not hurry :)

I will look your link!
B
12
S
3
Posts: 40
Reputation: 1,304

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests