2D Toolkit Forum

2D Toolkit => Support => Topic started by: dotty on June 23, 2013, 11:34:02 pm

Title: Looping through a tilemap's tiles to find out if a tile has a collider
Post by: dotty on June 23, 2013, 11:34:02 pm
Hello, does anyone know how to loop through a tilemap to find out if a tile has a collider or not?
Title: Re: Looping through a tilemap's tiles to find out if a tile has a collider
Post by: unikronsoftware on June 24, 2013, 12:09:16 am
1. Get the tileId for a tile.
2. The tileId for the tile = the sprite collection spriteId. So...
tk2dSpriteDefinition def = tilemap.SpriteCollectionInst.spriteDefinitions[tileId];
3. if (def.colliderType != ColliderType.Unset) it has a collider of some form.
Title: Re: Looping through a tilemap's tiles to find out if a tile has a collider
Post by: dotty on June 24, 2013, 10:30:11 am
Yeah, after I posted this message I thought the best way would be to use getTileByPosition (or whatever the method is called), then loop it. I thought there might be an array holding all tiles and their position. I was hoping to be able to loop an array then check that tile.