2D Toolkit Forum

2D Toolkit => Support => Topic started by: iopixel on December 23, 2012, 10:00:03 pm

Title: [TileMap] Convenience method to convert a world coordinate to a tile coordinate
Post by: iopixel on December 23, 2012, 10:00:03 pm
Hi,

I can do this myself using the camera / tilemap parameters but before doing it, can you tell me there is a method to convert a world coordinate to a tile coordinate ?

Thanks !
Title: Re: [TileMap] Convenience method to convert a world coordinate to a tile coordinate
Post by: unikronsoftware on December 26, 2012, 03:02:28 am
tileMap.GetTileFracAtPosition will transform a tile position from world -> tile space. The rounded / floored x & y values should give you the tile indices in both axes. The function returns false if the world position is out of bounds.
Title: Re: [TileMap] Convenience method to convert a world coordinate to a tile coordinate
Post by: iopixel on December 26, 2012, 10:08:53 pm
Great, thanks !