Cocos2d-x v4 doesn't load Tiled Editor v1.10.1 CSV TMX Tile Maps correctly

I’ve posted this similar stack overflow post: tiled - Loading and rendering a Tilemap TMX using Cocos2d-x v4 C++ - Stack Overflow

In short, I have a very simple test scene in C++ Cocos2d-x-4 that is loading a tmx file generated from Tiled.

– I’ve even following using the same sample png desert texture “tmw_desert_spacing.png” provided in the examples of Tiled Map Editor, – and it seems that it renders in Cocos2d-x-4 just very strange results.

virtual bool init() 
  {
    auto map = TMXTiledMap::create("tmx/desert.tmx");
    layer = map->getLayer("Desert");

    auto& mapSize = layer->getLayerSize();

    auto visibleSize = Director::getInstance()->getVisibleSize();

    this->addChild(map);

    return true;
  }

Seen above, is just super simple code for loading in a tmx file.

Expected output:

But get output like this:
image


Below is the tmx file generated from Tiled Map Editor:

<?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.10.1" orientation="orthogonal" renderorder="right-up" width="4" height="4" tilewidth="34" tileheight="34" infinite="0" nextlayerid="2" nextobjectid="1">
 <tileset firstgid="1" source="trees.tsx"/>
 <layer id="1" name="Trees" width="4" height="4">
  <data encoding="csv">
1,7,4,2,
3,8,5,6,
1,7,4,2,
3,8,5,6
</data>
 </layer>
</map>

The reason I found out, is that the newest version of Tiled Map Editor adds in whitespace in the CSV format for Layer Data, – which breaks Cocos2d-x v4 importing.

changing the generated tmx file from Tiled Map Editor above to below, now properly loads and renders in Cocos2d-x v4

<?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.10.1" orientation="orthogonal" renderorder="right-up" width="4" height="4" tilewidth="34" tileheight="34" infinite="0" nextlayerid="2" nextobjectid="1">
 <tileset firstgid="1" source="trees.tsx"/>
 <layer id="1" name="Trees" width="4" height="4">
  <data encoding="csv">1,7,4,2,3,8,5,6,1,7,4,2,3,8,5,6</data>
 </layer>
</map>

Can anyone care to help resolve this issue? I don’t want to have to manually go into these generated files everytime and fix them.

I used your example from stack Overflow:
Works with axmol:
image

It seems like this issue was actually fixed and merged in this PR, but it was after Cocos2d-x v4.0 was released. Merge in those changes and it should fix the issue.