Why I get this exception when i create a dialog?

1.1k Views Asked by At

I'm trying to create a dialog in my Libgdx game and I'm getting this Error:

Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException:      com.badlogic.gdx.utils.GdxRuntimeException: No com.badlogic.gdx.scenes.scene2d.ui.Window$WindowStyle registered with name: default"

this is a part of my json file:

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

There are 1 best solutions below

6
On

You have some styles defined in your json file, but you don't have a default style defined. Also you posted the styles for the ProgressBar, not the Window.

When you define styles you need to always define a style with the name default. This style will be chosen in the case you didn't pass a style name parameter while creating your windows.

To fix your json, you could add a style with name default or just rename one of your existing ones to default. See the json uiskin example:

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

For more details check out the libgdx skins wiki