Jump to content

Get tile value from a tilemap


shtanton
 Share

Recommended Posts

Hi

I have a tilemap that's I'm using but I need to get the value of a tile at a certain location on the tilemap and haven't been able to find any way to do this

Basically one of my layers is for hitboxes so in order for my collision script to work, the program needs to see whether there is a hitbox at the location the player is trying to move to

Thanks in advance ;)

Link to comment
Share on other sites

Hi,what do you mean by "certain location" ?

if the coordinates are given in tile values then you have to get the tile using the getTile method, if they are in pixel values then use the getTileWorldXY method. After getting the tile, you can read its index property to get its type or its properties public property to get its "properties" (defined in Tiled)

See this example for tile properties.

 

Link to comment
Share on other sites

On 5/23/2016 at 4:18 PM, askariwa said:

Hi,what do you mean by "certain location" ?

if the coordinates are given in tile values then you have to get the tile using the getTile method, if they are in pixel values then use the getTileWorldXY method. After getting the tile, you can read its index property to get its type or its properties public property to get its "properties" (defined in Tiled)

See this example for tile properties.

 

Thanks, this really helped!

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...