我有一个问题,我真的是新的光滑,我正在sidescroller。我试图在stateBasedGame中加载一个spritesheet。但是,当我运行/调试游戏运行,但不显示图像。下面是代码:slick2D spritesheet不加载
//private static Map<String, Image> images;
private static Map<String, SpriteSheet> sprites;
//private static Map<String, Sound> sounds;
public Resources() {
//images = new HashMap<String, Image>();
sprites = new HashMap<String, SpriteSheet>();
//sounds = new HashMap<String, Sound>();
try {
sprites.put("tiles", loadSprite("resources/tiles.png", 32, 32));
} catch (SlickException e) {
e.printStackTrace();
}
}
private Image loadImage(String path) throws SlickException {
return new Image(path, false, Image.FILTER_NEAREST);
}
private SpriteSheet loadSprite(String path, int tw, int th) throws SlickException {
return new SpriteSheet(loadImage(path), tw, th);
}
public static Image getSpriteImage(String getter, int x, int y) {
sprites.get(getter).getSubImage(x, y);
return null;
}
,并在游戏状态,我把这个:
Resources.getSpriteImage("tiles", 0, 0);
我仔细检查了道路,这是正确的。请帮帮我!
嗯,我使用的代码,但现在我有这个NullPointerException: – DavidIsTheName 2014-10-18 18:52:46