Game Development Community

Tile Picking and Mounting Sprites to Tiles

by Jeremy Noetzelman · in Torque Game Builder · 03/04/2005 (8:58 am) · 3 replies

I'd like to be able to click on a tile and mount a sprite on that tile. As far as I can tell, the only real way to do this is get the tile virtual x/y from the TileLayer and add a mount point to the TileLayer with the correct coordinates to center it over the Tile in question.

Is there a better way to do this?

#1
03/04/2005 (10:24 am)
The problem you'll have here is that the mount is to the object window, not to a specific tile, just like all the objects in T2D. If you were to pan the tilemap, it wouldn't move.

- Melv.
#2
03/04/2005 (11:17 am)
I don't plan on panning the tilemap, I was planning on using the camera for changing whats visible.

That said, what's the best way for me to link (hard or soft) a sprite to a specific tile? Just wing it with math?
#3
03/04/2005 (12:39 pm)
Jeremy: Why use tilemaps at all then? Use sprites all the way? Alternately, instead of mounting sprites on tiles, why not use all tiles?

Have you used the "fxTileLayer2D::pickTile(%worldPosition)" function that allows you to pass a world-position (possibly from a mouse routine) and it returns which logicial tile was clicked on?

You could use this to set a tile-layer in-front of it and set the same tile-position. This would even work with rotating/panning tiles.

- Melv.