Nifty-GUI文本无法呈现

时间:2015-03-10 15:54:18

标签: java opengl lwjgl nifty-gui

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

这是我现有的代码:

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>

但文字没有出现在屏幕上:

enter image description here

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

知道问题是什么吗?

1 个答案:

答案 0 :(得分:0)

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

  

字体= “接口/字体/ Adob​​eArabic.fnt”

相关问题