Hello,
I have been playing around with cocos2d and the new TMXTiledMap class for the past day. I am using 0.8.1-beta, and I am aware that this might well be a bug, but I am very new to cocos2d so I wanted to confirm here first.
I created a 512x512 sprite sheet with PNG-24 files, using zwoptex. Imported that into Tiled, and designed a simple test level of 40x40px tiles, for a total of 12x8 grid. Loaded this into a Layer within a Scene as shown in the sample code:
map = [[TMXTiledMap tiledMapWithTMXFile:@"level2.tmx"] retain];
This rendered the level almost perfectly, the only issue was the missing first row (which is a known issue I believe), so I moved the map one tile down:
[map setPosition:ccp(0.0, -40.0)];
So far so good. Now I tried to get the GID's by iterating through the tiles, exactly as shown in the TMXReadWriteTest's updateCol method. The results had nothing to do with the actual map. I tried with single and double layered files, both to no avail. I do get some GID's, but they are definitely in the wrong coordinates, the only one that matches correctly is ccp(0, 0).
Here is the code that I use to log the tiles:
TMXLayer *layer = (TMXLayer *)[map getChildByTag:0];
CGSize layerSize = [layer layerSize];
for (int x = 0; x < layerSize.width; x++) {
for (int y = 0; y < layerSize.height; y++) {
NSLog(@"Tile at %d x %d: %d", x, y, [layer tileGIDAt:ccp(x, y)]);
}
}
Any suggestions? I assume this is a bug, but I might be missing something as well, so I just wanted to confirm.
Thanks!