2014-10-20 76 views
1

我想啓動一個BitmapFont,當我運行我的項目時它的工作原理,但是當我開始運行項目然後運行它時,我得到了這個。Libgdx不能從jar文件加載字體

Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeExcepti 
on: Error reading file: assets\texture\font.fnt (Absolute) 
     at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:144) 
     at com.badlogic.gdx.graphics.g2d.BitmapFont$BitmapFontData.<init>(Bitmap 
Font.java:835) 
     at com.badlogic.gdx.graphics.g2d.BitmapFont.<init>(BitmapFont.java:106) 
     at catt.main.Game.create(Game.java:105) 
     at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplic 
ation.java:136) 
     at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplicati 
on.java:114) 
Caused by: java.io.FileNotFoundException: assets\texture\font.fnt (The system ca 
nnot find the path specified) 
     at java.io.FileInputStream.open(Native Method) 
     at java.io.FileInputStream.<init>(FileInputStream.java:138) 
     at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:140) 
     ... 5 more 

這是我如何加載字體。

fontTexture = new Texture("assets/texture/font.tga"); 
buttonFont = new BitmapFont(new FileHandle("assets/texture/font.fnt"), new TextureRegion(fontTexture), true); 
titleFont = new BitmapFont(new FileHandle("assets/texture/font.fnt"), new TextureRegion(fontTexture), true); 

它們都是公共靜態的字段。

+0

看看[這個問題](http://stackoverflow.com/q/3369794/4125191) - 默認情況下,文件來自文件系統,而不是來自jar。 – RealSkeptic 2014-10-20 09:06:56

回答