【问题标题】:libgdx crashes when i add dialogs当我添加对话框时,libgdx 崩溃
【发布时间】:2014-10-10 21:05:09
【问题描述】:

我有问题

我已经开始使用 libgdx 编写我的第一个游戏并创建了菜单 我正在尝试为 about 按钮提供打开文本对话框的功能

但是当我添加代码时,游戏在运行时崩溃

任何人都可以将我链接到制作文本对话框的指南吗?

因为我发现的所有东西都不适合我......

我找到并使用的代码:

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);

堆栈跟踪

    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

【问题讨论】:

  • 堆栈跟踪在哪里?
  • @donfuxx 你说的堆栈跟踪是什么意思?
  • 这里可以找到解释:stackoverflow.com/questions/23353173/…
  • @donfuxx 嘿,我添加了堆栈跟踪,但我没有看到任何由行引起的
  • 您的皮肤中没有使用名称“dialog”注册的 WindowStyle。

标签: java android libgdx scene2d


【解决方案1】:

根据你的代码和异常:

没有使用名称注册的 com.badlogic.gdx.scenes.scene2d.ui.Window$WindowStyle:对话框

你需要在你的 skin.json 文件中有一个名为“dialog”的 WindowStyle:

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

【讨论】:

  • 或者省略“dialog”参数,将使用“default”对话框样式(即skin.json文件中名为“default”的窗口样式)例如new Dialog("Dialog", skin ) { . . .等
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-05-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多