我正在关注 Slick2D 网站上的教程,在将图像加载到我的程序时,我收到一条错误消息:
Tue Nov 01 14:12:47 EDT 2011 INFO:Slick Build #274
Tue Nov 01 14:12:47 EDT 2011 INFO:LWJGL Version: 2.8.1
Tue Nov 01 14:12:47 EDT 2011 INFO:OriginalDisplayMode: 1024 x 768 x 32 @60Hz
Tue Nov 01 14:12:47 EDT 2011 INFO:TargetDisplayMode: 800 x 600 x 0 @0Hz
Tue Nov 01 14:12:48 EDT 2011 INFO:Starting display 800x600
Tue Nov 01 14:12:48 EDT 2011 INFO:Use Java PNG Loader = true
Tue Nov 01 14:12:48 EDT 2011 INFO:Controllers not available
Exception in thread "main" java.lang.RuntimeException: Resource not found: C:\Users\Andrew\workspace\SirSlime\data\images\lang.jpg
at org.newdawn.slick.util.ResourceLoader.getResourceAsStream(ResourceLoader.java:69)
at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.java:169)
at org.newdawn.slick.Image.<init>(Image.java:196)
at org.newdawn.slick.Image.<init>(Image.java:170)
at org.newdawn.slick.Image.<init>(Image.java:158)
at org.newdawn.slick.Image.<init>(Image.java:136)
at awesome.Main.init(Main.java:33)
at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:390)
at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:314)
at awesome.Main.main(Main.java:19)
该行:
找不到资源:C:\Users\Andrew\workspace\SirSlime\data\images\lang.jpg\
让我感到困惑,因为我试图加载的图片是在那个确切的区域。这是我用来加载的代码:
// ship = new Image("../../data/images/ship.png"); Does not work
// land = new Image("../../data/images/land.jpg"); Does not work
ship = new Image("C:\\Users\\Andrew\\workspace\\SirSlime\\data\\images\\ship.png");
land = new Image("C:\\Users\\Andrew\\workspace\\SirSlime\\data\\images\\lang.jpg");