Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tiled + zlib = not supported? #700

Closed
toovy opened this issue Dec 19, 2012 · 2 comments
Closed

Tiled + zlib = not supported? #700

toovy opened this issue Dec 19, 2012 · 2 comments

Comments

@toovy
Copy link

toovy commented Dec 19, 2012

Hi,

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);
break;
case 'zlib':
//Not Implemented
break;
// Uncompressed
case null:
case '':
if (encoding == "base64") {
layer._tiles = cc.Codec.Base64.decodeAsArray(nodeValue, 4);
}
else {
layer._tiles = cc.StringToArray(nodeValue);
}
break;
default:
cc.Assert(this.getLayerAttribs() != cc.TMXLayerAttribNone, "TMX tile map: Only base64 and/or gzip/zlib maps are supported");
}

@dingpinglv
Copy link
Contributor

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

@toovy
Copy link
Author

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 pushed a commit that referenced this issue Dec 21, 2012
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants