LibGDX - dialog box name does not fit

I have successfully added my own font to the default .json file and it will display, however I am getting some strange size problems. In particular, when I try to create a dialogue. Here's what it looks like: Sizes
Ignore the fact that it says β€œand”
As you can see, the title doesn't fit and the button seems a little big ... Here's how I create the dialog:

Dialog d = new Dialog("Error", RBResources.gameSkin);
        d.add(new Label("You cannot continue and empty game.", RBResources.gameSkin));
        TextButton b = new TextButton("Ok", RBResources.gameSkin);
        d.button(b);
        d.show(this);

So the skin is initialized:

gameSkin = new Skin(Gdx.files.internal("skins/uiskin.json"));

All I did to add a font was create a font using Hiero, add it to the directory using .json, and change the link to the BitmapFont file from "default.fnt" to "text.fnt" (text is what I called the font).

+4
2

, , : NinePatch, .atlas .png.


. JSON LibGdx.

LibGdx Skin. .json .atlas .png, , Button s, TextButton s, Dialog s ..

LibgGdx

JSON
JSON . Dialog. Window, WindowStyle ( ), JSON WindowStyle.

com.badlogic.gdx.scenes.scene2d.ui.Window$WindowStyle: {
default: { titleFont: default-font, background: default-window, titleFontColor: white },
dialog: { titleFont: default-font, background: default-window, titleFontColor: white, stageBackground: dialogDim }
},

, , Dialog s, Window s. , , JSON . , , .fnt .png , JSON, . BitmapFont, Hiero, : https://github.com/libgdx/libgdx/wiki/Hiero. JSON, . , . stageBackground - , , . dialogDim, TintedDrawable JSON. - ATLAS.

ATLAS
ATLAS TextureRegion ATLAS. , , . default-window ATLAS:

default-window
  rotate: false
  xy: 1, 20
  size: 27, 29
  split: 4, 3, 20, 3
  orig: 27, 29
  offset: 0, 0
  index: -1

, , , rotate , , . xy - x y TextureRegion ATLAS. size - x . split , TextureRegion ( ATLAS), , : https://github.com/libgdx/libgdx/wiki/Ninepatches. orig, , size. offset 0, 0, , xy . index of -1 , ATLAS, .


. , , , ( ), ATLAS. ATLAS . , , , Skin JSON, .
, :)

+4

StrongJoshua , NinePatch, PNG, NinePatch .

, , , NinePatch. "pixelly", .

NinePatch scale() :

NinePatchDrawable dialogBack = (NinePatchDrawable)dialog.getBackground();
dialogBack.getPatch().scale(2.0f,2.0f);

: , scale() , , , . , , , :

NinePatch dialogBack = skin.getPatch("default-window");
dialogBack.scale(2.0f,2.0f);
0

Source: https://habr.com/ru/post/1545288/


All Articles