SerializationException读取json文件

时间:2014-02-27 17:41:52

标签: json libgdx

我正在尝试为我的游戏创建一个皮肤。我得到以下例外:

com.badlogic.gdx.utils.SerializationException:读取文件时出错:images / uiskin.json。

这是代码:

private void rebuildStage () {
    skinOkomfo = new Skin(
        Gdx.files.internal(“images/oapacker-ui.json”),
        new TextureAtlas(“images/uiskin.atlas”)
    );

    skinLibgdx = new Skin(
        Gdx.files.internal(“images/uiskin.json”),
        new TextureAtlas(”images/uiskin.atlas”)
    );

    // build all layers

    Table layerBackground = buildBackgroundLayer();
    Table layerObjects = buildObjectsLayer();
    Table layerLogos = buildLogosLayer();
    Table layerControls = buildControlsLayer();
    Table layerOptionsWindow = buildOptionsWindowLayer();

    // assemble stage for menu screen

    stage.clear();

    Stack stack = new Stack();

    stage.addActor(stack);

    stack.setSize(Constants.VIEWPORT_GUI_WIDTH,

    Constants.VIEWPORT_GUI_HEIGHT);

    stack.add(layerBackground);
    stack.add(layerObjects);
    stack.add(layerLogos);
    stack.add(layerControls);
    stage.addActor(layerOptionsWindow);

}

这是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.Slider$SliderStyle:{
          default-horizontal:{
             background:default-slider,
             knob:default-slider-knob
          }
       },
       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 :(得分:0)

我一直在反对这一点。您可以在uiskin.json文件中看到它们是“默认滚动”值,但如果您转到uiskin.atlas,则没有为“default-scroll”定义任何内容。我认为这是错误的来源。