shtanton

Get tile value from a tilemap

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 ;)

Share this post


Link to post
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.

 

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.