gpt4 book ai didi

libgdx 中的 json 文件

转载 作者:行者123 更新时间:2023-12-01 15:42:39 25 4
gpt4 key购买 nike

我尝试在我的 libgdx 项目中添加 json 皮肤文件,但出现错误:

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)

我的代码:

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 }
}
}

我在 asset/gfx 文件夹中有:abc.fnt、abc.png、uiskin.json我不知道我做错了什么?我搜索了一下,但一无所获。感谢您的帮助。

最佳答案

Window$WindowStyle ( WindowStyle Javadoc ) 没有font 字段

可用的字段是:

  • 背景
  • 标题字体
  • 标题字体颜色
  • 舞台背景

你应该做类似的事情。

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 }
}

关于libgdx 中的 json 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19534828/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com