I create a healthbar from a
Ninepatch background and "fill" texture. However, it starts overlapping it's patches when it gets very small.
Is there anything I can do about this? Is there a way to tell the
Ninepatch not to draw the stretchable area and just draw a part of it or perhaps shrink in size?
float maxFill = getWidth() - horizontalOffset * 2; float currentFill = (maxFill / max) * current; //This is how I currently fix it. //Whenever it gets less then it's own total size it just does not get smaller. if (currentFill < minFill) currentFill = minFill; fill.draw(batch, getX() + horizontalOffset, getY() + verticalOffset, currentFill, drawHeight - verticalOffset * 2);
The not really desirable work arounds I have thought about are.
- Don't use rounded ends
- Dump the ninepatch and start masking/clipping
- Stop the Ninepatch from getting too small like I did above.
Zoom in on the image I posted, in the red healthbar you can see the issue. The stretchable area is being drawn over the unstretchable area. The desired effect of the bar should just clip the rounded unstretachable area when getting smaller then the 2 unstretchable parts together.