[SOLVED]Width VS. Opacity

For questions about using Classic.

Post » Tue Jun 14, 2011 6:23 am

Hey, I'm having an issue involving changing the width of an object in real time.

I hope this hasn't been answered elsewhere. I did my best to search around the forums.

I'm trying to implement a health bar that decreases as the variable 'health' decreases.

I set the hotspot of the health bar to the left of the sprite. The width of the sprite decreases in increments in accordance with the variable decreasing.

Everything works properly, save for the fact that as the width of the sprite approaches 0, the opacity of the sprite begins to decrease. I have checked and made sure that I have no events relating to the opacity of that health bar sprite.

Basically, it seems that opacity is linked to width change for some odd reason. :?

For the record, I'm using v0.99.96. (Because I'm working on an old project)

Any help, or knowledge pertaining to the subject matter, would be greatly appreciated.

Thanks in advance.
B
3
G
3
Posts: 18
Reputation: 911

Post » Tue Jun 14, 2011 6:52 am

Does the health bar fill its own borders, with no transparency?
Like if you scale an image that has a transparency around the image the transparency will be scaled as well.
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Tue Jun 14, 2011 7:03 am

There are a few examples in the HUD section of the tutorial list HERE that may be of use.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
120
S
28
G
68
Posts: 4,844
Reputation: 48,289

Post » Tue Jun 14, 2011 7:45 am

@newt - The health bar has no transparent areas whatsoever.

@zenox98 - Thankyou, but I've checked the ones pertaining to health bars already, and they haven't been of much use to me. They are very old posts, and the caps do not work with my current version of construct.
B
3
G
3
Posts: 18
Reputation: 911

Post » Tue Jun 14, 2011 4:29 pm

It's because of the graphics card filtering the sprite's texture.

If you use a black very rectangular texture like 500 x 50 with a white background you can see clearly what it's doing. This happens when a sprite is stretched or compressed a lot on either width or height alone. You can see the opposite effect using a 5 x 50 texture and resizing it to 500 x 50. What seems to fix it is to use a square texture like 256 x 256 instead, something not so rectangular. Or even better, use the panel object.
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Post » Tue Jun 14, 2011 4:38 pm

Yes, as Arima said. For something like a growing or shrinking bar I would advise using the panel object or the tiled background object.

An example of the panel object use for a health bar can be found in Verve! (I give this link, because it definitely works with your version)
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Tue Jun 14, 2011 5:34 pm

@Arima - Many thanks. That explanation was exactly what I needed. I used a square instead, and simply sized it up accordingly on runtime. Now my health bar is working like a charm with no dietary stretch marks. :lol:

@tulamide - I have yet to look into using the panel object for health bars, but if I do, I'll be sure to look at Verve! Thanks.

Speedy replies = Profit. Thanks all.
B
3
G
3
Posts: 18
Reputation: 911


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests