Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 加载错误LibGDX/Scene2d_Java_Json_Libgdx_Scene2d - Fatal编程技术网

Java 加载错误LibGDX/Scene2d

Java 加载错误LibGDX/Scene2d,java,json,libgdx,scene2d,Java,Json,Libgdx,Scene2d,我明白了: 线程LWJGL应用程序中的异常 com.badlogic.gdx.utils.SerializationException:读取文件时出错: ui/skin.json 我试图为我的scene2D ui加载一个皮肤,但完全失败了 不管怎样,当我转到这个类时,这个错误会在load方法中抛出,所以这是一个加载问题,对吗 还有,为什么不加载 @Override public void show() { // Creates our atlas from our png file c

我明白了:

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

我试图为我的scene2D ui加载一个皮肤,但完全失败了

不管怎样,当我转到这个类时,这个错误会在load方法中抛出,所以这是一个加载问题,对吗

还有,为什么不加载

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

    }

}
非常直截了当地说,跟随德米特迷的视频,这样我就可以了解更多关于节目结构的内容了,这让我开始紧张起来,尽管我设法解决了这个问题

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

我把它改成了标准的WindowsAriel字体,现在我正试图弄明白为什么自定义字体不起作用


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

这可能是JSON解析中的问题。尝试用JsonReader直接读取/加载文件,或者尝试简化文件,看看是否可以消除解析错误并缩小问题范围。我在盯着堆栈跟踪坐了两个小时后设法修复了它……如果我向下读取而不是将第一行作为实际错误,这会有所帮助。我会留下一个答案