Android Libgdx - 加载数据/ uiskin.json时出错

时间:2015-02-28 06:42:24

标签: android json libgdx

我试图使用相同的"结构系统"来尝试使用这些样本来开发我的测试,但是在加载uiskin.json时出现错误

我尝试了几件事......但没有。

提前致谢!

CODE:

    public static void load() {
        TextureAtlas textureAtlas = new TextureAtlas("data/PigTest.pack");
        fallingManAnim = new Animation(0.2f, textureAtlas.findRegion("falling1"), textureAtlas.findRegion("falling2"));
        platform = textureAtlas.findRegion("platform");
        fallingManSplash = textureAtlas.findRegion("rip");
        backgroundTexture = new Texture(Gdx.files.internal("data/back.jpg"));

        skin = new Skin(Gdx.files.internal("data/uiskin.json"));
    }
}

ERROR:

    ush.android E/AndroidRuntime﹕ FATAL EXCEPTION: GLThread 182
Process: com.indev.push.android, PID: 1651
com.badlogic.gdx.utils.SerializationException: Error reading file: data/uiskin.json
        at com.badlogic.gdx.scenes.scene2d.ui.Skin.load(Skin.java:97)
        at com.badlogic.gdx.scenes.scene2d.ui.Skin.<init>(Skin.java:74)
        at com.indev.push.Assets.load(Assets.java:27)
        at com.indev.push.PushButton.create(PushButton.java:9)
        at com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:241)
        at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1511)
        at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1239)
 Caused by: com.badlogic.gdx.utils.SerializationException: Error reading file: data/uiskin.json
        at com.badlogic.gdx.utils.Json.fromJson(Json.java:683)
        at com.badlogic.gdx.scenes.scene2d.ui.Skin.load(Skin.java:95)
            at com.badlogic.gdx.scenes.scene2d.ui.Skin.<init>(Skin.java:74)
            at com.indev.push.Assets.load(Assets.java:27)
            at com.indev.push.PushButton.create(PushButton.java:9)
            at com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:241)
            at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1511)
            at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1239)
 Caused by: com.badlogic.gdx.utils.SerializationException: Serialization trace:
vScroll (com.badlogic.gdx.scenes.scene2d.ui.ScrollPane$ScrollPaneStyle)
        at com.badlogic.gdx.utils.Json.readFields(Json.java:787)
        at com.badlogic.gdx.utils.Json.readValue(Json.java:902)
        at com.badlogic.gdx.scenes.scene2d.ui.Skin$1.readValue(Skin.java:404)
        at com.badlogic.gdx.utils.Json.readValue(Json.java:834)
        at com.badlogic.gdx.scenes.scene2d.ui.Skin$2.readNamedObjects(Skin.java:425)
        at com.badlogic.gdx.scenes.scene2d.ui.Skin$2.read(Skin.java:414)
        at com.badlogic.gdx.scenes.scene2d.ui.Skin$2.read(Skin.java:410)
        at com.badlogic.gdx.utils.Json.readValue(Json.java:873)
        at com.badlogic.gdx.scenes.scene2d.ui.Skin$1.readValue(Skin.java:404)
        at com.badlogic.gdx.utils.Json.fromJson(Json.java:681)
        ... 7 more
 Caused by: com.badlogic.gdx.utils.GdxRuntimeException: No Drawable, NinePatch, TextureRegion, Texture, or Sprite registered with name: default-scroll
        at com.badlogic.gdx.scenes.scene2d.ui.Skin.getDrawable(Skin.java:283)
        at com.badlogic.gdx.scenes.scene2d.ui.Skin.get(Skin.java:139)
        at com.badlogic.gdx.scenes.scene2d.ui.Skin$1.readValue(Skin.java:403)
        at com.badlogic.gdx.utils.Json.readFields(Json.java:780)

uiskin.json

{
com.badlogic.gdx.graphics.g2d.BitmapFont: { default-font: { file: default.fnt } },
com.badlogic.gdx.graphics.Color: {
    green: { a: 1, b: 0, g: 1, r: 0 },
    white: { a: 1, b: 1, g: 1, r: 1 },
    red: { a: 1, b: 0, g: 0, r: 1 },
    black: { a: 1, b: 0, g: 0, r: 0 }
},
com.badlogic.gdx.scenes.scene2d.ui.Skin$TintedDrawable: {
    dialogDim: { name: white, color: { r: 0, g: 0, b: 0, a: 0.45 } }
},
com.badlogic.gdx.scenes.scene2d.ui.Button$ButtonStyle: {
    default: { down: default-round-down, up: default-round },
    toggle: { down: default-round-down, checked: default-round-down, up: default-round }
},
com.badlogic.gdx.scenes.scene2d.ui.TextButton$TextButtonStyle: {
    default: { down: default-round-down, up: default-round, font: default-font, fontColor: white },
    toggle: { down: default-round-down, up: default-round, checked: default-round-down, font: default-font, fontColor: white, downFontColor: red }
},
com.badlogic.gdx.scenes.scene2d.ui.ScrollPane$ScrollPaneStyle: {
    default: { vScroll: default-scroll, hScrollKnob: default-round-large, background: default-rect, hScroll: default-scroll, vScrollKnob: default-round-large }
},
com.badlogic.gdx.scenes.scene2d.ui.SelectBox$SelectBoxStyle: {
    default: {
        font: default-font, fontColor: white, background: default-select,
        scrollStyle: default,
        listStyle: { font: default-font, selection: default-select-selection }
    }
},
com.badlogic.gdx.scenes.scene2d.ui.SplitPane$SplitPaneStyle: {
    default-vertical: { handle: default-splitpane-vertical },
    default-horizontal: { handle: default-splitpane }
},
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 }
},
com.badlogic.gdx.scenes.scene2d.ui.ProgressBar$ProgressBarStyle: {
    default-horizontal: { background: default-slider, knob: default-slider-knob },
    default-vertical: { background: default-slider, knob: default-round-large }
},
com.badlogic.gdx.scenes.scene2d.ui.Slider$SliderStyle: {
    default-horizontal: { background: default-slider, knob: default-slider-knob },
    default-vertical: { background: default-slider, knob: default-round-large }
},
com.badlogic.gdx.scenes.scene2d.ui.Label$LabelStyle: {
    default: { font: default-font, fontColor: white }
},
com.badlogic.gdx.scenes.scene2d.ui.TextField$TextFieldStyle: {
    default: { selection: selection, background: textfield, font: default-font, fontColor: white, cursor: cursor }
},
com.badlogic.gdx.scenes.scene2d.ui.CheckBox$CheckBoxStyle: {
    default: { checkboxOn: check-on, checkboxOff: check-off, font: default-font, fontColor: white }
},
com.badlogic.gdx.scenes.scene2d.ui.List$ListStyle: {
    default: { fontColorUnselected: white, selection: selection, fontColorSelected: white, font: default-font }
},
com.badlogic.gdx.scenes.scene2d.ui.Touchpad$TouchpadStyle: {
    default: { background: default-pane, knob: default-round-large }
},
com.badlogic.gdx.scenes.scene2d.ui.Tree$TreeStyle: {
    default: { minus: tree-minus, plus: tree-plus, selection: default-select-selection }
}
}

1 个答案:

答案 0 :(得分:1)

确保您下载了&#34; raw&#34;文件,如果你从github下载它。

enter image description here