# Coordinates different between Tiled editor and my game

So I have been using Tiled map editor to create my map for my game. I'm using Libgdx to load and draw the map.

The problem is that the coordinate from objects placed in tiled do not seem to be the same when they are using in my game. It seems to be just the y value, as I have tried a few different positions and the x value seems to be okay.

I think it may be because Libgdx coordinate systems starts in the bottom left instead of the top left, but I'm not sure. And I'm not sure how to get around it.

In Tiled:

In game:

The black square is being drawn at the x and y values grabbed from the object.

I get the values from this function once the map loads:

    public Vector2 getStartingPosition()
{
for (TiledObjectGroup group : map.objectGroups) {
for (TiledObject object : group.objects) {
if ("playerSpawn".equals(object.name))
return new Vector2(object.x, object.y);
}
}

return new Vector2(0,0);
}

• "I think it may be because Libgdx coordinate systems starts in the bottom left instead of the top left" I think you could be right. Does it change the position of other boxes? I see you have collision boxes? (red)? are they in the correct spot once loaded and rendered? or is it only the objects layer that is off? Feb 11 '13 at 7:16
• It's only the object layer that seems to be off. The map seems to be drawn properly. I haven't even tried the collision layer yet, I'll give that a shot and see what happens. Feb 11 '13 at 12:30
• Okay, I tested the collision layer and the coordinates seem to be off for that layer aswell. Feb 11 '13 at 13:34
• Not sure if this helps, but try flipping the y axis : return new Vector2(object.x, -object.y); Feb 11 '13 at 14:06
• Nope, didn't work. Made it wildly out of place :P Feb 11 '13 at 14:08

y = mapHeight - tilesize - y;