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);
}
}
//Was not found, return default spawn
return new Vector2(0,0);
}