首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >添加对话框时libgdx崩溃。

添加对话框时libgdx崩溃。
EN

Stack Overflow用户
提问于 2014-10-10 21:05:09
回答 1查看 1.6K关注 0票数 0

嗯,我有个问题

我已经开始用libgdx编写我的第一个游戏了,我创建了一个菜单,我正在尝试给“关于”按钮一个函数来打开一个文本框。

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

有人能把我链接到制作文本对话框的指南上吗?

因为我发现的一切都不适合我.

我找到并使用的代码:

代码语言:javascript
复制
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);

堆栈跟踪

代码语言:javascript
复制
    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
EN

回答 1

Stack Overflow用户

发布于 2014-10-11 23:55:38

根据您的代码和例外情况:

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

您需要在您的WindowStyle文件上有一个名为“对话框”的skin.json:

代码语言:javascript
复制
com.badlogic.gdx.scenes.scene2d.ui.Window$WindowStyle:
{
 dialog: { titleFont: <your-font>, titleFontColor: <your-font-color (optional)>, background: <your-background-drawable (optional)>},
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26308018

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档