2 years ago
#49806
Dubua
Error reading file: uiskin.json in Netbeans using LibGDX (Trying to create a TextField in LibGDX)
Hello good day everyone I've been trying to add a textfield but I am getting an error after another
I created the project, tested it using desktop,html, androidstudio, making use of Shaperenderer, another using an image other than badlogic.jpg and ScreenAdapter and they worked fine... I did all this tests before trying to create a TextField with libgdx, for some reason when testing I realize my core folder doesn't have an assests folder and the "core/assests" folder is at desktop\build\resources\main and it works properly but I am not sure if this could be a problem, as mentioned before I can use images from desktop, android and html if a place them there
Ok so now to the explanation:
This is the code in the class
public class SelectImages extends ScreenAdapter implements InputProcessor{
GameClass game;
TextureAtlas atlasFile = new TextureAtlas(Gdx.files.internal("uiskin.atlas.txt"));
Skin uiSkin = new Skin(Gdx.files.internal("uiskin3.json"));
Table table = new Table();
public SelectImages(GameClass game) {
this.game = game;
uiSkin.addRegions(atlasFile);
TextField txtFieldNum = new TextField("", uiSkin);
txtFieldNum.setPosition(24,73);
txtFieldNum.setSize(88, 14);
table.add(txtFieldNum);
}
I tried this LibGDX - Error reading file: uiskin.json removing com.badlogic.gdx.scenes.scene2d.ui.TextTooltip$TextTooltipStyle:
I got the json file from a github website it was as BitmapFont, Color.... Changed manually to com.badlogic.gdx.graphics.g2d.BitmapFont,com.badlogic.gdx.graphics.Color...
Also created one using the same code.. just open a txt and saved as .json
The whole Json file looks like:
{
com.badlogic.gdx.graphics.g2d.BitmapFont: { default-font: { file: default.fnt.txt } },
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 },
gray: { a: 1, b: 0.8, g: 0.8, r: 0.8 },
},
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, disabled: default-round },
toggle: { parent: default, checked: default-round-down }
},
com.badlogic.gdx.scenes.scene2d.ui.TextButton$TextButtonStyle: {
default: { parent: default, font: default-font, fontColor: white, disabledFontColor: gray },
toggle: { parent: default, checked: default-round-down, 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: { parent: default, 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: { parent: default-horizontal },
default-vertical: { parent: default-vertical }
},
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 }
},
com.badlogic.gdx.scenes.scene2d.ui.TextTooltip$TextTooltipStyle: {
default: {
label: { font: default-font, fontColor: white },
background: default-pane, wrapWidth: 150
}
},
}
This is the default.fnt inside my uiskin3.json file the name goes asdefault.fnt.txt otherwise it will not be found
info face="Droid Sans" size=17 bold=0 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=0,0,0,0 spacing=1,1
common lineHeight=20 base=18 scaleW=256 scaleH=128 pages=1 packed=0
page id=0 file="uiskin.png"
chars count=96
char id=32 x=0 y=0 width=0 height=0 xoffset=0 yoffset=16 xadvance=4 page=0 chnl=0
..................//
And the uiskin.png file is also the
I got this error
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.SerializationException: Error reading file: uiskin.json
at com.badlogic.gdx.scenes.scene2d.ui.Skin.load(Skin.java:106)
at com.badlogic.gdx.scenes.scene2d.ui.Skin.<init>(Skin.java:83)
at com.pokedemon.game.selectimages.SelectImages.<init>(SelectImages.java:20)
at com.pokedemon.game.selectimages.GameClass.create(GameClass.java:19)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:150)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:127)
Caused by: com.badlogic.gdx.utils.SerializationException: Error reading file: uiskin.json
at com.badlogic.gdx.utils.Json.fromJson(Json.java:797)
at com.badlogic.gdx.scenes.scene2d.ui.Skin.load(Skin.java:104)
... 5 more
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: No Drawable, NinePatch, TextureRegion, Texture, or Sprite registered with name: white
at com.badlogic.gdx.scenes.scene2d.ui.Skin.getDrawable(Skin.java:323)
at com.badlogic.gdx.scenes.scene2d.ui.Skin.newDrawable(Skin.java:355)
at com.badlogic.gdx.scenes.scene2d.ui.Skin$5.read(Skin.java:590)
at com.badlogic.gdx.utils.Json.readValue(Json.java:1000)
at com.badlogic.gdx.scenes.scene2d.ui.Skin$1.readValue(Skin.java:469)
at com.badlogic.gdx.utils.Json.readValue(Json.java:966)
at com.badlogic.gdx.scenes.scene2d.ui.Skin$2.readNamedObjects(Skin.java:518)
at com.badlogic.gdx.scenes.scene2d.ui.Skin$2.read(Skin.java:507)
at com.badlogic.gdx.scenes.scene2d.ui.Skin$2.read(Skin.java:501)
at com.badlogic.gdx.utils.Json.readValue(Json.java:1000)
at com.badlogic.gdx.scenes.scene2d.ui.Skin$1.readValue(Skin.java:469)
at com.badlogic.gdx.utils.Json.fromJson(Json.java:795)
... 6 more
BUILD SUCCESSFUL in 2s
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: No Drawable, NinePatch, TextureRegion, Texture, or Sprite registered with name: **white**
at com.badlogic.gdx.scenes.scene2d.ui.Skin.getDrawable(Skin.java:323)
Because of that name: white I procedeed to check the json file, changed white to red
com.badlogic.gdx.scenes.scene2d.ui.Skin$TintedDrawable: {
dialogDim: { name: white, color: { r: 0, g: 0, b: 0, a: 0.45 } },
},
to
com.badlogic.gdx.scenes.scene2d.ui.Skin$TintedDrawable: {
dialogDim: { name: red, color: { r: 0, g: 0, b: 0, a: 0.45 } },
},
Mainly to see if the white will change to red and it did, I tried changed rgba values but got the same, so I deleted it, to see the changes
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.SerializationException: Error reading file: uiskin3.json
at com.badlogic.gdx.scenes.scene2d.ui.Skin.load(Skin.java:106)
at com.badlogic.gdx.scenes.scene2d.ui.Skin.<init>(Skin.java:83)
at com.pokedemon.game.selectimages.SelectImages.<init>(SelectImages.java:21)
at com.pokedemon.game.selectimages.GameClass.create(GameClass.java:19)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:150)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:127)
Caused by: com.badlogic.gdx.utils.SerializationException: Error reading file: uiskin3.json
at com.badlogic.gdx.utils.Json.fromJson(Json.java:797)
at com.badlogic.gdx.scenes.scene2d.ui.Skin.load(Skin.java:104)
... 5 more
Caused by: com.badlogic.gdx.utils.SerializationException: Serialization trace:
{}."com.badlogic.gdx.scenes.scene2d.ui.Button$ButtonStyle".default.down
down (com.badlogic.gdx.scenes.scene2d.ui.Button$ButtonStyle)
at com.badlogic.gdx.utils.Json.readFields(Json.java:908)
at com.badlogic.gdx.scenes.scene2d.ui.Skin$1.readFields(Skin.java:495)
at com.badlogic.gdx.utils.Json.readValue(Json.java:1073)
at com.badlogic.gdx.scenes.scene2d.ui.Skin$1.readValue(Skin.java:469)
at com.badlogic.gdx.utils.Json.readValue(Json.java:966)
at com.badlogic.gdx.scenes.scene2d.ui.Skin$2.readNamedObjects(Skin.java:518)
at com.badlogic.gdx.scenes.scene2d.ui.Skin$2.read(Skin.java:507)
at com.badlogic.gdx.scenes.scene2d.ui.Skin$2.read(Skin.java:501)
at com.badlogic.gdx.utils.Json.readValue(Json.java:1000)
at com.badlogic.gdx.scenes.scene2d.ui.Skin$1.readValue(Skin.java:469)
at com.badlogic.gdx.utils.Json.fromJson(Json.java:795)
... 6 more
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: No Drawable, NinePatch, TextureRegion, Texture, or Sprite registered with name: default-round-down
at com.badlogic.gdx.scenes.scene2d.ui.Skin.getDrawable(Skin.java:323)
at com.badlogic.gdx.scenes.scene2d.ui.Skin.get(Skin.java:156)
at com.badlogic.gdx.scenes.scene2d.ui.Skin$1.readValue(Skin.java:468)
at com.badlogic.gdx.utils.Json.readFields(Json.java:901)
... 16 more
I removed com.badlogic.gdx.scenes.scene2d.ui.Button$ButtonStyle the error jumped to com.badlogic.gdx.scenes.scene2d.ui.TextButton$TextButtonStyle and so on, but I dont know the reason
This is inside my atlas file but I don't know if I should use it and how
......// tree-plus rotate: false xy: 155, 35 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 white rotate: false xy: 129, 31 size: 3, 3 orig: 3, 3 offset: 0, 0 index: -1
GameClass extends game and it is use to setScreen(new SelectImages(this));
java
json
netbeans
libgdx
textfield
0 Answers
Your Answer