[SOLVED]Width VS. Opacity

This forum is currently in read-only mode.
From the Asset Store
Full game Construct 2 and Construct 3 to post on Google Play
  • 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.

  • 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.

  • There are a few examples in the HUD section of the tutorial list HERE that may be of use.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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.

  • 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)

  • 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.

    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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)