How to add sprite to specific coordinates?

Hello guys.

Unfortunately i didn’t find answer in documentation.

For example i have map created via Tiledmap. Size is 15x15 tiles. Can i add sprite to the tile at coordinates 7x14 without any physics?

I’ve tried to get coordinates manualy via touch event(  map.pixelsToTiles(event.x, event.y) ) and then i want attach sprite to the tile with received coordinates. 

It works but if i will move the camera -  map.pixelsToTiles(event.x, event.y)  will return same coordinates even if map was moved out of camera. 

For example top left corner will always return coordinates 1,1. 

Can Dusk correct calculate at which tile was tap?   

Thanks in advance

Touch events give content coordinates for touch positions, but Dusk takes local coordinates for pixelsToTiles. This is easily fixed with Corona’s contentToLocal function:

local localX, localY = map.layer[1]:contentToLocal(event.x, event.y) local tileX, tileY = map.pixelsToTiles(localX, localY)
  • Caleb

Many thanks to you :slight_smile:

Touch events give content coordinates for touch positions, but Dusk takes local coordinates for pixelsToTiles. This is easily fixed with Corona’s contentToLocal function:

local localX, localY = map.layer[1]:contentToLocal(event.x, event.y) local tileX, tileY = map.pixelsToTiles(localX, localY)
  • Caleb

Many thanks to you :slight_smile: