Reputation: 5495
I was reading from https://github.com/libgdx/libgdx/wiki/Ninepatches
My image
toast_patch = new NinePatch(texture, 10, 10, 10, 10);
Output:
I'm only getting the edges.. (ignore the text) What should I do?
Upvotes: 2
Views: 1348
Reputation: 29
graySkin = new Skin()
grayAtlas = new TextureAtlas(Gdx.files.internal("ui/gray.pack"));
grayAtlas.createPatch("patch");
graySkin.addRegions(grayAtlas);
grayButtonStyle = new TextButton.TextButtonStyle();
grayButtonStyle.font = fontB44;
grayButtonStyle.up = graySkin.getDrawable("patch");
//gray.pack
gray.9.png
format: RGBA8888
filter: Nearest,Nearest
repeat: none
patch
rotate: false
xy: 1, 1
size: 100, 100
split: 17, 17, 19, 19
orig: 100, 100
offset: 0, 0
index: -1
Upvotes: 0
Reputation: 25177
You're using the full width of the texture for the 'corners' so there are no pixels left to stretch through the edges or "middle" of the button. A "nine patch" should have nine patches. You've divvied the texture up into four pieces (the four corners), leaving no texture data for the other five parts. Try:
toast_patch = new NinePatch(texture, 7, 7, 7, 7);
(Or anything that doesn't sum to 20 along one axis. The first argument is the number of left-edge pixels, the second is the number of right-edge pixels, implicitly any remaining pixels are used for the 'middle' section. Similarly for the top and bottom.)
Upvotes: 1
Reputation: 7708
Use this picture as a guide. I used your image on your question.
Upvotes: 1