Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Tiled + zlib = not supported? #700

toovy opened this Issue Dec 19, 2012 · 2 comments


None yet
2 participants

toovy commented Dec 19, 2012


it took me some time to figure out what I were doing wrong while loading a tmx tilemap. I started out by installing tiled, loading a simple png tileset and by creating a basic tilemap. I saved it and tried to load it just as in the samples. But actually I got strange errors:

cocos2d: Warning: TMX Layer Kachelebene 1 has no tiles
Assertion failed: TextureAtlas.initWithTexture():texture should not be null
Uncaught TypeError: Cannot read property 'width' of undefined

I tried the sample maps and they did load. Finally I debugged the parser and came to the conclusion that zlib is not yet supported, but the cc.Assert before accepts it. As tiled standard compression setting is zlib (at least on my mac) it should be mentioned somewhere and a readable error should be thrown.

Here the excerpt from CCTMXXMLParser.js (note line 1 and the case 'zlib'):

cc.Assert(compression == null || compression == "gzip" || compression == "zlib", "TMX: unsupported compression method");
switch (compression) {
case 'gzip':
layer._tiles = cc.unzipBase64AsArray(nodeValue, 4);
case 'zlib':
//Not Implemented
// Uncompressed
case null:
case '':
if (encoding == "base64") {
layer._tiles = cc.Codec.Base64.decodeAsArray(nodeValue, 4);
else {
layer._tiles = cc.StringToArray(nodeValue);
cc.Assert(this.getLayerAttribs() != cc.TMXLayerAttribNone, "TMX tile map: Only base64 and/or gzip/zlib maps are supported");


dingpinglv commented Dec 20, 2012

Yes, TMX not support zlib, but we will add this feature soon.

toovy commented Dec 20, 2012

It is not a problem that the feature is missing, but the asset should be altered to throw an readable error if a zlib tilemap is loaded. Thanks.

linshun added a commit that referenced this issue Dec 21, 2012

Merge pull request #706 from dingpinglv/iss700_ZlibSupport
fixed #700 add zlib support for cc.TMXXMLParser
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment