Reputation: 599
I try to add json skin file in my libgdx project but I have an error:
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: com.badlogic.gdx.utils.SerializationException: Error reading file: gfx/uiskin.json
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:113)
Caused by: com.badlogic.gdx.utils.SerializationException: Error reading file: gfx/uiskin.json
Caused by: com.badlogic.gdx.utils.SerializationException: Error reading file: gfx/uiskin.json
Caused by: com.badlogic.gdx.utils.SerializationException: Field not found: font (com.badlogic.gdx.scenes.scene2d.ui.Window$WindowStyle)
My code:
public void create() {
Gdx.graphics.setContinuousRendering(false);
ui = new Stage();
skin = new Skin(Gdx.files.internal("gfx/uiskin.json"));
Gdx.input.setInputProcessor(ui);
label = new Label("fps", skin);
label.setText("fps:"+Gdx.graphics.getFramesPerSecond());
window = new Window("alarm", skin);
window.setPosition(10, 10);
ui.addActor(window);
}
public void render() {
Gdx.gl.glClearColor(0.2f, 0.2f, 0.2f, 1);
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
ui.draw();
}
json
{
com.badlogic.gdx.graphics.g2d.BitmapFont: {
medium: { file: abc.fnt }
},
com.badlogic.gdx.scenes.scene2d.ui.Label$LabelStyle: {
default: { font: medium }
},
com.badlogic.gdx.scenes.scene2d.ui.Window$WindowStyle: {
default: { font: medium }
}
}
I have in asset/gfx folder: abc.fnt, abc.png, uiskin.json I don’t know what am I doing wrong? I searched about it but found nothing. Thanks for help.
Upvotes: 3
Views: 4278
Reputation: 3505
There is no font
field for Window$WindowStyle
(WindowStyle Javadoc)
The available fields are:
You should be doing something similar to this.
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 }
}
Upvotes: 3