I'm trying to make a function to check if a cell in Tiled can be passed, by accessing a Boolean custom property I gave each tile. This is (part of) my code.
...
public boolean isCellPassable(int column, int row, MapLayer layer) {
boolean canPass = Boolean.valueOf((Boolean) ((TiledMapTileLayer) layer).getCell(column, row).getTile().getProperties().get("can_pass"));
if (canPass == true) {
return true;
}
else {
return false;
}
}
public void displayHUD(ShapeRenderer hud) {
System.out.println(isCellPassable(0, 6, Main.level1.getLayers().get("base")));
...
And even though in the isCellPassable
function I cast it to a Boolean, for some reason I still get this error ..
Exception in thread "LWJGL Application" java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Boolean
.. on the line where I set the value of canPass
.