I'm new to Slick2D, and I'm using Tiled to make .tmx map.
for (int xAxis = 0; xAxis < map.getWidth(); xAxis++) {
for (int yAxis = 0; yAxis < map.getHeight(); yAxis++) {
int tileID = map.getTileId(xAxis, yAxis, 0);
String value = map.getTileProperty(tileID, "blocked", "0");
int valueInInt = Integer.parseInt(value);
if (valueInInt == 1) {
blocked[xAxis][yAxis] = true;
}
}
}
This works fine when the blocks are on the same layer with others, however, if I put the blocks on a different Tile layer, I can't get the right TileProperty anymore.
Why did it happen? What can I do with that or any ideals?
Thanks a lot.
The third parameter to TiledMap.getTileId() is the layerIndex
. You would have to use that to select the layer where you're searching for tiles with the "blocked" property set to "1".