TMXTiledMap returns somehow translated object y coordinates, what's the catch?

Hi!

I’m familiarizing myself with TMXTiledMap class. I made a couple of test objects (1x1 tile objects) for my .tmx:

 <objectgroup id="2" name="Objects">
  <object id="1" name="SpawnPoint" x="64" y="544" width="32" height="32"/>
  <object id="2" name="TestPoint1" gid="10" x="0" y="32" width="32" height="32"/>
  <object id="3" name="TestPoint2" gid="10" x="0" y="1600" width="32" height="32"/>
 </objectgroup>

Map is like this:

<map version="1.2" tiledversion="1.3.2" orientation="orthogonal" renderorder="right-down" compressionlevel="-1" width="50" height="50" tilewidth="32" tileheight="32" infinite="0" nextlayerid="3" nextobjectid="5">

Thus, map size in pixels is 1600x1600.

Returned y values for the three objects are:

  1. SpawnPoint y = 1024 (for 544)
  2. TestPoint1 y = 1536 (for 32)
  3. TestPoint2 y = -32 (for 1600)

It seems that y’s are somehow translated. But why is one even a negative number? What is the translation for? Can I configure it somehow?

Advices:

  • Do not use .tmx files. Use an image that contains the tiles instead. Cocos doesn’t support .tsx files yet. You could have some problems.

  • The max map size that cocos supports, as I know, is 128x128 (tiles and px, width/height). Do not try to use bigger maps than this. If you need it, you should concatenate different maps. I’ve never did it but I know that this is possible.

Hope it helps.

I use a single image that contains all tiles, and the size of the map is 50x50 tiles, each tile being 32x32 pixels. There is margin=1 and spacing=1, since all tiles are surrounded by 1px line.

I’m actually going throught this tutorial:

and trying to replicate it in cocos2d-x 4.0.

Still, I think the implementation of TiledMap must be very buggy, as one of the coordinates ended up being negative, which should never happen.

I’ve have some oddness in the Creator version. But basically the Y is inverted. So the bottom most tile is 0 and y increases as you move up the screen.
Yours is offset by 32 it seems. So the “anchor” point is at 32 but since it is Y flipped it is at 1568. Hence going down to testPoint 2 puts you at -32 and then +32 is 1536. and then 1024 is 544. so newY = Y-1632

However such logic woks for me on windows, but fails on iOS.