Clipping a progress bar?

I want to clip a horizontal full art progress bar in GUI (can’t simply be stretched). The only way I can think of to do it conveniently is to have a transparent png of the size of the clipping area be a parent of the full art progress bar to be clipped, and then move the x positions of the clipping texture and the progress bar in opposite directions in equal amounts as the progress fills so that the bar appears to remain in the same position but part of it moves outside of the clipping area.

Is there a better way that I’m forgetting about?

Can’t you use a stencil mask: https://www.defold.com/manuals/gui-clipping/

Or maybe I’m not understanding the effect you’re after?

Stencil mask is what I’m using currently with the clipping. But I can’t like arbitrarily define a rectangle easily? I want to maintain the scale and position of the clipped area, but clip off the right side of it as a value goes between 0 and 1. The current method I’m using works but seems hacky.

This is what I’m doing. I’ll publish an example of the method soon and maybe make an easy to use module.

Not sure how you do it currently, but having a box node that you set the size of (increasing in x axis), should work?

2 Likes

That is a much better method and not hacky, exactly what I wanted.

Create box node, enable clipping on it, set its alpha to 0, set its size mode to manual, set a child under it, set the child to not inherent alpha, set size of box node.

4 Likes

I’m not sure why you need to alpha 0? You can set the clipper node to not be visible, which is better for performance and intended to be used for this reason. Search for “visible clipper” in the documentation here.

6 Likes

0%20-%20XP

The language for it was changed in Editor 2. Maybe it should say “Clipping Mask Visible”?

Do “organizational nodes” have same performance issue even though they have 0,0 size?

@erik.angelin Can you look into the naming? @Pkeod having 0,0 size won’t skip the instance in the rendering pipeline (create vertices etc.), it’s currently still sent through so there’s no gain there. The GPU will likely skip the triangle setup, but that’s about the only benefit you’ll gain.

1 Like