我有一个可以在Windows和Mac上正常运行的游戏,但是在Ubuntu中找不到该图像。这就是问题所在,找不到图像。
我正在尝试使用Java Web Start在Ubuntu 12.1上运行它
这是我用来加载图像的方法:
this.getClass().getClassLoader().getResource("pixelapp/wavelogy/images/boat.jpg");
我的包是pixelapp.wavelogy
如果您确实需要它,这是我的代码片段:
String folder = "pixelapp/wavelogy/images/";
fileName[count] = folder + "boat.jpg";
pTex[count] = TextureIO.newTexture(
cl.getResource(fileName[count]), false, null);
代码片段的结尾。
关于如何解决这个问题的任何想法?
编辑:
Unable to use Firefox's proxy settings. Using "DIRECT" as proxy type.
Error loading texture pixelapp/wavelogy/images/redboat.jpg
Error loading texture pixelapp/wavelogy/images/pinkboat.jpg
Exception in thread "Timer-0" java.lang.NullPointerException
at pixelapp.wavelogy.Wavelogy.display(Wavelogy.java:2739)
at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:373)
at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:358)
at jogamp.opengl.GLAutoDrawableBase$2.run(GLAutoDrawableBase.java:280)
at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:655)
at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:594)
at com.jogamp.newt.opengl.GLWindow.display(GLWindow.java:543)
at com.jogamp.opengl.util.AWTAnimatorImpl.display(AWTAnimatorImpl.java:74)
at com.jogamp.opengl.util.AnimatorBase.display(AnimatorBase.java:142)
at com.jogamp.opengl.util.FPSAnimator$1.run(FPSAnimator.java:128)
at java.util.TimerThread.mainLoop(Timer.java:555)
at java.util.TimerThread.run(Timer.java:505)
X11Util.Display: Shutdown (JVM shutdown: true, open (no close attempt): 2/2, reusable (open, marked uncloseable): 0, pending (open in creation order): 2)
X11Util: Open X11 Display Connections: 2
X11Util: Open[0]: NamedX11Display[:0, 0x927bf60, refCount 1, unCloseable false]
X11Util: Open[1]: NamedX11Display[:0, 0x9207ba8, refCount 1, unCloseable false]
最佳答案
如果您仅尝试以下操作将不起作用:
this.getClass().getClassLoader().getResource("images/some_image.jpg");
因为我想您的课程在pixelapp.wavelogy包中,所以在pixelapp / wavelogy文件夹中,那里也有images文件夹。