Get what cell is tapped/clicked on tmx maps

121 views Asked by At

So I have a map which I have gotten the cells from and stored in a cell 2d array

Cells[][] cells;

My question is if I click one of the cells on the map, how do I get the cell that was clicked (X,Y).

1

There are 1 answers

0
bemeyer On BEST ANSWER

You do get the world coordinates form the clickevent. After that you calculate which tile it would be thats touched.
You take the x value of the touch devide it by the Tilesize same for y. After that you cast it to an integer and you do have the x,y values for the tile that is touched.