I am trying to create images for a loading bar in libGDX. I came across the
NinePatch class and I was hoping to use it for this loading bar, since stretching images with a plain
Sprite looks terrible. Does anyone have any examples on how to use this class? I have done some searching around and I've gotten it to work but the image I use just comes through as slightly transparent and gray. It just doesn't look like the same image. The actual loading bar itself seems to work fine as I just set the width of the foreground loading image. Here is the code I am using so far...
// Class vars private NinePatch loadingBackground; private NinePatch loadingForeground; ... // In my constructor loadingBackground = new NinePatch(new Texture(Gdx.files.internal("loadingback.png")), 8, 8, 8, 8); loadingForeground = new NinePatch(new Texture(Gdx.files.internal("loadingfore.png")), 8, 8, 8, 8); ... // Drawing batch.begin(); loadingBackground.draw(batch, x, y, width, height); loadingForeground.draw(batch, x, y, loadingWidth, height); batch.end();
I am open to any other suggestions on how I should implement this as well.