get cell in tiled map

Hello, i wish to know how can i get cell in tiled map, … i know what you are thinking? LibGDX? no actually i wish to do it without libGDX, i wish to do it with libtiled - https://github.com/bjorn/tiled/tree/master/util/java/libtiled-java

here is an example how to use libtiled - https://github.com/bjorn/tiled/blob/master/util/java/tmxviewer-java/src/TMXViewer.java

But i played with it and couldn’t find how to get cell…

I wish to use libtiled and not libgdx, because i want to do collision detection with multiplayer server, and i dont want to install libgdx in the server, just as simple as possible.

Thanks in advance, if i will find a solution, be sure i will update you all (and maybe i will make a guide because there is 0 documentation for tiled maps)

Hey, well i couldnt find a solution but here is some information

Here how you can get a tileset tile (doesn’t related to the actual map) -

TMXMapReader reader = new TMXMapReader();
Map map = reader.readMap("assets/map.tmx");
map.getTileSets().get(index).getTile(index);    // That's how you get a tile / cell

If you want to get tile properties -

map.getTileSets().get(index).getTile(index).getProperties();

You can get any information about the tile, lets say we want to check if the tile contains key grass

map.getTileSets().get(0).getTile(1).getProperties().containsKey("grass");

Correct me if i am wrong :wink:
But i still can’t find a way to get a cell inside the map.

ANY HELP?

Still can’t solve it… please help? :frowning:
maybe it has something with the map xml file?

Ohh come on… how did u make multiplayer with tiled maps? how the server handled collision detection?

No idea with the library you are using but with libgdx is something like this:


((TiledMapTileLayer)map.getLayers().get(0)).getCell(x,y);

The thing is i want to do collision detection in the server, and installing libgdx in the server its not a good idea… so how can i make collision detection of tiled map in the server?

Didn’t you answer your question yourself right there?
To be honest it is really difficult to understand what you are asking…

It’s hard to understand probably because you dont really know what tileset is… tilesets are the tiles that are going to be used in the map, like this -http://nethackwiki.com/mediawiki/images/7/7c/Vanilla_tiles.png
I showed you an example how you can take tile in a tileset… not in a map, in a tileset.

Now what i am asking is how can i get a tile / cell inside my map.
for example, if i want to get the tile / cell in my map at the position (x=5,y=6), how can i do that? without libgdx?

Hope you understand, Thanks

I’m not quite familiar with libtiled since I use Libgdx but this getTileAt(int tx, int ty) seems to do the trick

Wow…Looks great, thanks!
but how should i use it? getTileAt() returns null everytime i use it. any ideas?