1

我得到这个:

线程“LWJGL 应用程序”com.badlogic.gdx.utils.SerializationException 中的异常:读取文件时出错:ui/skin.json

我正在尝试为我的 scene2D ui 加载皮肤,但完全失败了。

无论如何,当我去上课时,这个错误会在加载方法中抛出,所以这是一个加载问题,对吧?

另外,为什么加载不出来?

@Override
public void show() {

    // Creates our atlas from our png file containing all the sprites
    atlas = new TextureAtlas("ui/atlas.atlas");

    // Create a stage, everything goes on the stage
    stage = new Stage();
    // A skin for the stage
    skin = new Skin(Gdx.files.internal("ui/skin.json"), atlas);

该文件在那里,准确命名,项目清理,刷新和重新导入。甚至尝试将其移动到资产文件夹。只是不断地抛出错误。

这是我的 json 文件:

{

    "com.badlogic.gdx.graphics.Color": {
        "white": { "r": 1, "g": 1, "b": 1, "a": 1 },
        "black": { "r": 0, "g": 0, "b": 0, "a": 1 },
        "red": { "r": 1, "g": 0, "b": 0, "a": 1 },
        "green": { "r": 0, "g": 1, "b": 0, "a": 1 },
        "blue": { "r": 0, "g": 0, "b": 1, "a": 1 }
    },

    "com.badlogic.gdx.graphics.g2d.BitmapFont": {
        "fontSFNightly": { "file": "fonts/fontSFNightly.fnt" }
    },

    "com.badlogic.gdx.scenes.scene2d.ui.Label$LabelStyle": {
        "heading": { "font": "fontSFNightly", "fontColor": "white" }
    },

    "com.badlogic.gdx.scenes.scene2d.ui.TextButton$TextButtonStyle": {
        "mainMenu": { "up": "button.up", "down": "button.down", "pressedOffsetX": 1, "pressedOffsetY": -1 }

    }

}

相当直截了当,跟随 dermetfans 的视频,这样我就可以了解更多关于程序结构的信息,还有什么不是,这开始让我紧张了,哈哈

4

1 回答 1

0

我设法修复它。

事实证明,从 JSON 文件中读取字体对象时出现了某种问题,我使用的是 1001fonts.com 的第三方字体,我不确定为什么它不会加载。

我将其更改为标准的 windows ariel 字体,我现在正试图找出自定义字体不起作用的原因。

因此这个问题在技术上是固定的。

于 2013-09-24T07:08:30.743 回答