Nice looking Healthbar

Get help using Construct 2

Post » Sat Nov 30, 2013 6:34 pm

Hi

I want to make a custom continuous growing healthbar where the fill is more then just one color.
And as you can see in the example below the healthbar should get a second fill layer in another color if the first one is full.
https://dl.dropboxusercontent.com/u/61284640/healthbar.capx

Is there a way to resize a sprite, without stretching it?
Like "cutting" some pixels from the top of the sprite.
Or does anybody have another idea how you can make this?Geru2013-11-30 18:35:31
B
20
S
3
G
2
Posts: 34
Reputation: 2,675

Post » Sat Nov 30, 2013 7:28 pm

[quote]Is there a way to resize a sprite, without stretching it?
Like "cutting" some pixels from the top of the sprite.[/quote]
Yes if you use tiledbackground. Though to get it to grow from the bottom up you need to flip the sprite and rotate it so that the origin is at the bottom.

healthbar.capx (r152)
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,650

Post » Sat Nov 30, 2013 7:55 pm

Another way to "cut" sprites would be one of the blend modes, check out the blend modes example that comes with the program. Ofc a tiledbackground will work better in this case.
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 787
Reputation: 3,786

Post » Sun Dec 01, 2013 2:22 am

Thanks guys for your reply, but the problem is tiledbackgrounds doesn't support animations. So I could use a static custom picture but no animations in there. Like you see in the example I'd like to use a "flow-effect".

The solution with blend modes is also great but only supports one fill of the healthbar, because "destionation out" uses the background as destination and no other sprite or background.

An option so resize a sprite like a tiledbackground would solve the problem, but the sprite object just allows to scaling picture at the moment :SGeru2013-12-01 02:23:52
B
20
S
3
G
2
Posts: 34
Reputation: 2,675

Post » Sun Dec 01, 2013 3:08 am

I don't know if this will help or not, but you could try it.

Instead of trying to resize the health bar, just create a new image and use that each time the health changes.

So, you would create another sprite or something with another health bar, and set it to appear when the player gets hurt, for example.

You'd have to set up some code to make the proper health bar visible or invisible as the situation calls for it.

You'd have to use something like instance variables attached to the player's health to tell it which health bar to spawn.

Ex: if health=3 then set healthbar3 to visible and rest to invisible.

Anyway, I'm still new to C2, so I don't know if this helped or not, but hey.
B
75
S
30
G
35
Posts: 340
Reputation: 22,896

Post » Sun Dec 01, 2013 10:26 am

Yeah you're right, it would be possible with a huge amount of different images.
You don't need to make new sprites, you just can make a healthbar sprite with 3 frames, set animationspeed to 0 and set the current frame to players health.
But in my case this would need a huge amount of frames (like 100 or more for each color) to make it smooth looking.
B
20
S
3
G
2
Posts: 34
Reputation: 2,675

Post » Sun Dec 01, 2013 11:57 am

Like this? (use spacebar to add to thermometer)

thermometer

This is done with a simple tiled background and one set height on spacebar released event.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sun Dec 01, 2013 12:00 pm

Oh just saw you'd want animation possibilities.
Just replace the tiled background object with another animationframe when needed. Destroy-create.
or use opacity with another object behind it.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sun Dec 01, 2013 12:05 pm

Using destination out or destination in should work perfectly too, just remember to set the layer to force own texture..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sun Dec 01, 2013 2:03 pm

@LittleStain Yes background would work but without animations.

But "force own texture" is exactly what I was looking for!
Thanks dude, works perfectly!!!
B
20
S
3
G
2
Posts: 34
Reputation: 2,675

Next

Return to How do I....?

Who is online

Users browsing this forum: nahima and 5 guests