Hi, I am using cocos2dx version 3.15.1 and want to import the tmx
file to my game
Not sure if I can ask here, but when importing the generated tmx
and get the layer, it just return null
the c++ code I use is as following:
auto tmap = TMXTiledMap::create("map/map.tmx");
auto layer = tmap->getLayer("gamemap"); //here layer is null
auto size = tmap->getMapSize();
CCLOG(" %f, %f", size.height, size.width);
auto sprite = layer->getTileAt(Vec2(1, 1));
And here is the tmx file opened as plain text:
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" tiledversion="1.0.2" orientation="orthogonal" renderorder="right-down" width="7" height="7" tilewidth="100" tileheight="100" nextobjectid="1">
<tileset firstgid="1" source="map.tsx"/>
<layer name="gamemap" width="7" height="7">
<data encoding="csv">
2,2,1,2,2,2,1,
2,2,2,2,2,1,1,
1,1,1,1,2,1,1,
1,1,2,1,1,2,1,
1,2,2,2,2,2,1,
1,1,1,1,1,1,1,
1,1,1,1,1,1,1
</data>
</layer>
</map>
I have tried csv
format as well as the base64
and xml
format.
Not sure what I have done wrong, if some one could give a hint will be
appreciated.
Thanks