In Tiled I have created object layer. Then i’ve created one object and named it “Spawn Point”. In this code i try read object with his coordinates:
Size size = m_map->getMapSize (); TMXObjectGroup* objectGroup = m_map->objectGroupNamed ("Player"); if ( objectGroup == NULL ) { log ( "Player not exist on tile map" ); return; } ValueMap SpawnPoint = objectGroup->objectNamed ( "SpawnPoint" ); int x = SpawnPoint.at ( "x" ).asInt(); int y = SpawnPoint.at ( "y" ).asInt();
Values of x and y are not correctly and if I create Sprite with this coord, it appear in some place, that different with real position of object
Any ideas?
Hi, I have the same problem.
Do you solved it?
@panor The x, y value is the point with pixel in Tiled editor with the ortho map, and the x value is upside-down. For iso map, Tiled do some rotation for it.
In our engine, we convert the x, y value to our engine coordinate system, but for the ortho map, we don’t do the rotation calculate, because it’s not a square, we can’t represent it use the ‘x’, ‘y’, ‘width’ and ‘height’ value. you can convert it by yourself.
We will use another representation for these value later.
Thanks for your response @boyu0.
Maybe something like this, I think:
CCPoint zp = ccp(x,y);
zp = CC_PIXELS_POINTS_TO_POINT(zp);