1
votes

I am using CCTMXTiledMap on cocos2dx-2.2, I created and added the tiled map like this:

// TileMap
CCTMXTiledMap *m_pTileMap = CCTMXTiledMap::create("tilesets/my-isometric-small.tmx");
float fPosX = m_pTileMap->getPositionX();
float fPosY = m_pTileMap->getPositionY();
CCLOG( "TileMapPos: %f, %f", fPosX, fPosY );
this->addChild(m_pTileMap);

The tiled map are created and rendered successfully, but out of position. I use CCTMXTiledMap::getPosition, CCTMXLayer::positionAt, and also examine the CCSprite that I get from CCTMXLayer::tileAt... all of them are returning the correct value based on cocos2d screen coordinate { (0, 0) from bottom left and increasing upward and rightward } However, when viewed on the screen, there is always a slight offset and I can't get where it come from. All the m_obOffsetPosition are confirmed to be zero...

By correct value, I mean the tiles are positioned in the pink area (I getPosition from each of the tile, create CCSprite for each, setPosition of each tile and add it to the screen... They show up in the pink area)

Image supposed to be positioned at shady pink boxes, but instead positioned in the blue area (the entire blue sea is the whole map)

Any ideas are highly appreciated... Thanks!!

Image supposed to be positioned at shady pink boxes, but instead positioned in the blue area (the entire blue sea is the whole map)

1
what is the screenshot supposed to convey? looks like a 3x3 iso map with randomly overlayed green and pink sprites. What exactly is the problem here, can you describe it more thoroughly please?LearnCocos2D
it is a 4x4 map, I'll change the map to make it clearerZennichimaro

1 Answers

1
votes

After wasting days trying to dissect tilemap_parallax_nodes in cocos2d-x, finally I figured out the culprit... it is the Layer Property cc_vertexz that cause it to be rendered off position. I haven't got the time to figure out how and why it works that way and since I'm not going to use it anyway (I just need flat, single layer, thus no need z order etc), so I just remove that property from all of my Layers and the problem is gone..

Hope it helps someone... Thanks!