LibGDX Removing tiles from TiledMap

Hi, so I know the way you remove tiles is with:


TiledMapTileLayer.setCell(x, y, Cell cell)

My problem is that I’m using Box2D, and I want to remove a tile after the player has come in contact with it’s
body. I can remove the Box2D body just fine, but to actually remove the tile would mean I need to know which row and column of the TiledMap that the collision occurred. So what is the easiest way to do this?

One option is to use “body.setUserData(Object o)” when creating your body so that it contains your tile object or some other object that contains the x,y data you need. Then when there is a collision call “collisionUserDataObj = (MyTileObject) body.getUserData()” to determine what to do.

It’s easy, just put null instead of cell object:

TiledMapTileLayer.setCell(x, y, null)