Get a tile in a layer by tile ID?

May 16, 2012 at 3:28 AM

I have a layer that specifically holds transparent tiles used for spawn points.


I'm trying to get a specific tile, using its ID, so I can place a sprite there automatically.

May 16, 2012 at 9:11 AM

To find the tiles, you would have to scan the whole layer and check tiles individually. As this is a slow process to do during the game loop, I suggest you do this once at startup, and build a list of spawn points. If you want something fancy like the ability to access spawn points close to the player, you could use a quadtree or some other space partitioning structure to hold the spawn points, instead of a simple list.