0

我在学习使用 slick 库时遇到了另一个问题。

我创建了一个简单的小地图,其中包含大小为50x50像素的5x5 块。我尝试了一切,但我仍然得到同样的错误。

这是我的课:

public class PlayState extends BasicGameState{

    int stateID = -1;

    private TiledMap map;


    public PlayState(int stateID){
        this.stateID = stateID;
    }

    @Override
    public void init(GameContainer gc, StateBasedGame sbg) throws SlickException {
    map = new TiledMap("src/resources/map.tmx","src/resources");
    }

    @Override
    public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException {
        map.render(0, 0);
    }

    @Override
    public void update(GameContainer gc, StateBasedGame sbg, int arg2) throws SlickException {

    }

    @Override
    public int getID() {
        return stateID;
    }

}

这是我的错误:

Tue Jul 30 13:34:09 CEST 2013 INFO:Slick Build #237
Tue Jul 30 13:34:09 CEST 2013 INFO:LWJGL Version: 2.9.0
Tue Jul 30 13:34:09 CEST 2013 INFO:OriginalDisplayMode: 1600 x 900 x 32 @60Hz
Tue Jul 30 13:34:09 CEST 2013 INFO:TargetDisplayMode: 1280 x 720 x 0 @0Hz
Tue Jul 30 13:34:09 CEST 2013 INFO:Starting display 1280x720
Tue Jul 30 13:34:09 CEST 2013 INFO:Use Java PNG Loader = true
Tue Jul 30 13:34:09 CEST 2013 INFO:Controllers not available
Tue Jul 30 13:34:09 CEST 2013 WARN:class org.newdawn.slick.opengl.PNGImageData failed to read the data
java.io.IOException: Transparent color not support in custom PNG Decoder
    at org.newdawn.slick.opengl.PNGImageData.loadImage(PNGImageData.java:78)
    at org.newdawn.slick.opengl.CompositeImageData.loadImage(CompositeImageData.java:62)
    at org.newdawn.slick.opengl.CompositeImageData.loadImage(CompositeImageData.java:43)
    at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.java:292)
    at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.java:254)
    at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.java:187)
    at org.newdawn.slick.Image.<init>(Image.java:192)
    at org.newdawn.slick.tiled.TileSet.<init>(TileSet.java:124)
    at org.newdawn.slick.tiled.TiledMap.load(TiledMap.java:661)
    at org.newdawn.slick.tiled.TiledMap.<init>(TiledMap.java:122)
    at main.states.PlayState.init(PlayState.java:23)
    at org.newdawn.slick.state.StateBasedGame.init(StateBasedGame.java:171)
    at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:393)
    at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:317)
    at main.Main.main(Main.java:40)
Tue Jul 30 13:34:09 CEST 2013 ERROR:Unsupport tiled map type: base64,zlib (only gzip base64 supported)
org.newdawn.slick.SlickException: Unsupport tiled map type: base64,zlib (only gzip base64 supported)
    at org.newdawn.slick.tiled.Layer.<init>(Layer.java:133)
    at org.newdawn.slick.tiled.TiledMap.load(TiledMap.java:676)
    at org.newdawn.slick.tiled.TiledMap.<init>(TiledMap.java:122)
    at main.states.PlayState.init(PlayState.java:23)
    at org.newdawn.slick.state.StateBasedGame.init(StateBasedGame.java:171)
    at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:393)
    at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:317)
    at main.Main.main(Main.java:40)
Tue Jul 30 13:34:09 CEST 2013 ERROR:Failed to parse tilemap
org.newdawn.slick.SlickException: Failed to parse tilemap
    at org.newdawn.slick.tiled.TiledMap.load(TiledMap.java:695)
    at org.newdawn.slick.tiled.TiledMap.<init>(TiledMap.java:122)
    at main.states.PlayState.init(PlayState.java:23)
    at org.newdawn.slick.state.StateBasedGame.init(StateBasedGame.java:171)
    at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:393)
    at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:317)
    at main.Main.main(Main.java:40)
Caused by: org.newdawn.slick.SlickException: Unsupport tiled map type: base64,zlib (only gzip base64 supported)
    at org.newdawn.slick.tiled.Layer.<init>(Layer.java:133)
    at org.newdawn.slick.tiled.TiledMap.load(TiledMap.java:676)
    ... 6 more
4

1 回答 1

1

我自己也遇到了这个错误 - 并解决了它。您需要确保您的地图属性图层格式设置为 Base64(gzip 压缩)。看起来这是 slick 所期望的格式。

至于 PNG 警告,显然 slick 不喜欢隔行扫描的 PNG 文件,所以保存为非隔行扫描图像

于 2013-08-18T01:45:46.417 回答