【问题标题】:Nifty-GUI text not rendering漂亮的 GUI 文本不呈现
【发布时间】:2015-05-12 03:49:14
【问题描述】:

我正在尝试为游戏创建一个简单的开始屏幕,并且我正在使用带有 nifty-gui 的 LWJGL。

这是我现有的代码:

public class Main { 

public Main(){
     if (!LwjglInitHelper.initSubSystems("Risk It")) {
          System.exit(0);
        }
     Nifty nifty = new Nifty(
                new LwjglRenderDevice(),
                new OpenALSoundDevice(),
                new LwjglInputSystem(),
                new AccurateTimeProvider());
     Game game = new Game(nifty);
}


    public static void main(final String[] args) throws Exception {
       Main main = new Main();
    }

}

public class Game {

    public Game(Nifty nifty){
        nifty.fromXml("util/tutorial.xml", "start");
        LwjglInitHelper.renderLoop(nifty, null);
        LwjglInitHelper.destroy();
    }

}

LwjglInitHelper 类可以在here找到

我的 XML 是:

<?xml version="1.0" encoding="UTF-8"?>
<nifty>
   <useStyles filename="nifty-default-styles.xml" />
   <useControls filename="nifty-default-controls.xml" />
   <screen id="start">
      <layer id="background" childLayout="center">
         <image filename="util/img/menuTexture.png" />
            <text text="My Cool Game" font="Venus_Rising.fnt" width="100%" height="100%" />
      </layer>
   </screen>
</nifty>

虽然文本没有出现在屏幕上:

.fnt 文件和 .png 文件在我的类路径中,在 src 文件夹中。

知道会是什么问题吗?

【问题讨论】:

    标签: java opengl lwjgl nifty-gui


    【解决方案1】:

    您的字体属性路径是问题所在。它需要 .fnt 文件的完整路径,例如:

    font="Interface/Fonts/AdobeArabic.fnt"

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-10-30
      • 1970-01-01
      • 2013-10-06
      • 2014-01-12
      • 1970-01-01
      • 2015-12-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多