We are migrating issue tracker of Cocos2d-x Project to Github, please create new issue there. Thanks.
CCTMXMap doesn't support TMX files reference external TSX files
CCTMXMap doesn't support TMX files reference external TSX files
Bug #2050 [Closed]
I tested it at tiled editor, and I think both description above and our engine both wrong with parse firstgid
.
This is how the firstgid
works at tiled editor:
1. firstgid
is ignored at tsx file, no mater what firstgid
value is setted at tmx or tsx file, it always start at 0.
2. gid=0
is always an empty tile at map, even if firstgid
is set to 0.
3. if firstgid
is not setted, it always equal to 0, even it setted at tsx file.
4. if firstgid
setted less than 0, it setted to 0
I will follow tiled editor to fix this bug.
This is reported by marmalade developer, the detail description is:
Hi guys
We are proposing the following fix to CCTMXMapInfo::startElement().
The current code does not seem to support TMX files referencing external TSX files; if the TMX file specifies a “firstgid” greater than 0 (which is usually the case… it’s usually 1) then this value is not used when parsing the TSX file, therefore all tile gids are offset incorrectly.
Ideally this code would respect any “firstgid” property already set on the TMX object; otherwise, it should simply set the value to 1 if it comes back from the parser as 0 (which is our implementation below):
(around line 365)
else
{
CCTMXTilesetInfo *tileset = new CCTMXTilesetInfo();
tileset~~>m_sName = valueForKey;
tileset~~>m_uFirstGid = (unsigned int)atoi(valueForKey(“firstgid”, attributeDict));
// MARMALADE
// m_uFirstGid must be minimum of 1, as 0 means “no tile”.
// If the TMX file references an external tileset (TSX), then the TSX file
// does not specify a “firstgid” property (at least, not if exported from the
// ‘Tiled’ editor. The code here either needs to inherit the “firstgid” property
// from the TMX file, or ensure that it is non-0
if (!tileset~~>m_uFirstGid)
tileset~~>m_uFirstGid = 1;
tileset~~>m_uSpacing = atoi);
tileset~~>m_uMargin = (unsigned int)atoi(valueForKey(“margin”, attributeDict));
CCSize s;
s.width = (float)atof(valueForKey(“tilewidth”, attributeDict));
s.height = (float)atof(valueForKey(“tileheight”, attributeDict));
tileset~~>m_tTileSize = s;
pTMXMapInfo~~>getTilesets()~~>addObject;
tileset~~>release();
}