firestoke
firestoke

Reputation: 1059

the display result of tiled map is wrong (using cocos2d-x 3.6)

this is what I created in my TiledMap Editor: enter image description here

But when I try to display it in simulator, it becomes this: enter image description here

You can see some of tile images are missed, some are wrong(the place where dirt.png should be become wall.png instead). I don't know why this happened. I follow the tutorial and add the following code in the HelloWorld project.

// create a TMX map
auto map = TMXTiledMap::create("tile/test.tmx");
addChild(map);

the content of test.tmx:

<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" renderorder="right-down" width="10" height="10" tilewidth="36" tileheight="36" nextobjectid="5">
 <tileset firstgid="1" name="test" tilewidth="36" tileheight="36">
  <tile id="0">
   <image width="36" height="36" source="dirt.png"/>
  </tile>
  <tile id="1">
   <image width="36" height="36" source="floor.png"/>
  </tile>
  <tile id="2">
   <image width="36" height="36" source="wall.png"/>
  </tile>
 </tileset>
 <layer name="Tile Layer 1" width="10" height="10">
  <data encoding="base64" compression="gzip">
   H4sIAAAAAAAAA2NkYGBgRMMwgM7GhRnQaEJmMaCJ4zILXS8+dbjsxOY+XO4g5FZ0M0GAiQBGV49PDwgAAKCoyOyQAQAA
  </data>
 </layer>
 <objectgroup name="Object Layer 1">
  <object id="1" name="SpawnPoint" x="125" y="133" width="67" height="62"/>
 </objectgroup>
</map>

Could any one give me a hand?

Upvotes: 0

Views: 583

Answers (1)

firestoke
firestoke

Reputation: 1059

okay... I have found why.... There are limitations which cocos2d-x support Tied Map Editor.

in this page, http://www.cocos2d-x.org/wiki/TileMap, it says:

Tiles:
- Embedded tiles are NOT supported (i.e., tilesets with embedded images).
- Only embedded tilesets are supported (i.e., the tileset is embedded, but not its images).
- supports at most 1 tileset per layer.

So.... each of tilesets MUST only contain one image. And... each of layer MUST only contain one tilesets. If you don't follow the rule while editing map in the Tied Map Editor. The result will become chaos like mine.

Upvotes: 1

Related Questions