【发布时间】:2014-10-17 18:52:59
【问题描述】:
我有一个问题,我对 slick 很陌生,我正在制作一个横向卷轴。我正在尝试在 stateBasedGame 中加载精灵表。但是当我运行/调试游戏时,它运行但不显示图像。代码如下:
//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;
}
我在 GameState 中放了这个:
Resources.getSpriteImage("tiles", 0, 0);
我仔细检查了路径,这是正确的。请帮我!
【问题讨论】:
标签: image 2d sprite tile slick2d