简体   繁体   中英

Slick2d Can't find image even though it's in the right area

I'm following the tutorials found on the Slick2D website, and upon loading Images to my program, I get an error that says:

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) 

The line:

Resource not found: C:\\Users\\Andrew\\workspace\\SirSlime\\data\\images\\lang.jpg\\

confuses me as the picture I'm trying to load IS in that exact area. This is the code I'm using to load:

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM