我有一個問題,我真的是新的光滑,我正在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