0
\$\begingroup\$

I understand what a nine patch is but I don't understand how to create one with code. I've made an image with a 1-pixel black border, but how do I turn that into a nine patch?

How do I make a nine patch that is not a cube image?

This is what is happening when I run:

patch = new NinePatch(new Texture(Gdx.files.internal("nineEmpty.9.png")), 4, 4, 13, 28);

enter image description here

enter image description here

I want it cut like this:

enter image description here

\$\endgroup\$
0

1 Answer 1

1
\$\begingroup\$

The documentation shows the correct usage of the NinePatch:

public NinePatch(TextureRegion region,
             int left,
             int right,
             int top,
             int bottom)

left - Pixels from left edge.
right - Pixels from right edge.
top - Pixels from top edge.
bottom - Pixels from bottom edge.

Additionally you can find a tutorial that covers the topic well here. I suggest you remeasure your graphic and adjust the inputs into the NinePath constructor accordingly. Make sure you don't have any white spaces that could throw off your calculations.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .