Karen Brockman
Karen Brockman

Reputation: 1

libgdx crashes when i add dialogs

well i am having a problem

i've started coding my first game with libgdx and i created the menu i am trying to give the about button a function to open a text dialog box

but when i add the code, the game crashes when i run it

can anyone link me to a guide on making a text dialog?

since everything i've found didnt work for me...

the code i have found & used :

new Dialog("Dialog", skin, "dialog") {
   protected void result (Object object) {

   }
}.text("texttexttext").button("Yes", true).button("No", false).key(Keys.ENTER, true)
   .key(Keys.ESCAPE, false).show(stage);

stack trace

    10-11 07:41:11.051    1716-1742/com.xxx.www.android E/AndroidRuntime﹕ FATAL EXCEPTION: GLThread 60
    Process: com.xxx.www.android, PID: 1716
    com.badlogic.gdx.utils.GdxRuntimeException: No com.badlogic.gdx.scenes.scene2d.ui.Window$WindowStyle registered with name: dialog
            at com.badlogic.gdx.scenes.scene2d.ui.Skin.get(Skin.java:145)
            at com.badlogic.gdx.scenes.scene2d.ui.Dialog.<init>(Dialog.java:62)
            at com.xxx.www.MainMenu$2.<init>(MainMenu.java:104)
            at com.xxx.www.MainMenu.show(MainMenu.java:104)
            at com.badlogic.gdx.Game.setScreen(Game.java:61)
            at com.xxx.www.Splash$1.onEvent(Splash.java:72)
            at aurelienribon.tweenengine.BaseTween.callCallback(BaseTween.java:380)
            at aurelienribon.tweenengine.BaseTween.updateStep(BaseTween.java:521)
            at aurelienribon.tweenengine.BaseTween.update(BaseTween.java:424)
            at aurelienribon.tweenengine.TweenManager.update(TweenManager.java:166)
            at com.xxx.www.Splash.render(Splash.java:47)
            at com.badlogic.gdx.Game.render(Game.java:46)
            at com.xxx.www.MyGdxGame.render(MyGdxGame.java:26)
            at com.badlogic.gdx.backends.android.AndroidGraphics.onDrawFrame(AndroidGraphics.java:414)
            at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1523)
            at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
10-11 07:41:15.411    1716-1716/com.xxx.www.android E/AndroidGraphics﹕ waiting for pause synchronization took too long; assuming deadlock and killing

Upvotes: 0

Views: 1668

Answers (1)

MadEqua
MadEqua

Reputation: 1142

According to your code and the exception:

No com.badlogic.gdx.scenes.scene2d.ui.Window$WindowStyle registered with name: dialog

you need to have a WindowStyle called "dialog" on your skin.json file:

com.badlogic.gdx.scenes.scene2d.ui.Window$WindowStyle:
{
 dialog: { titleFont: <your-font>, titleFontColor: <your-font-color (optional)>, background: <your-background-drawable (optional)>},
}

Upvotes: 1

Related Questions