Slick2d即使位于正确的区域,也无法找到图像

时间:2011-11-01 18:35:50

标签: java image slick2d

我正在关注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 \

让我感到困惑,因为我试图在那个确切的区域加载IS。这是我用来加载的代码:

 // 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"); 

1 个答案:

答案 0 :(得分:0)

很抱歉显而易见,但是在一个地方你使用文件名“lang.jpg”和另一个“land.jpg”,只是一个错字?