I am looping through object layer and there are certain objects(Rectangle Map object in my case) I want to remove based on certain condition, but I don't see any method to do this.
Asked
Active
Viewed 401 times
1 Answers
1
there are two methods for your use case:
com.badlogic.gdx.maps.MapObjects#remove(com.badlogic.gdx.maps.MapObject)
com.badlogic.gdx.maps.MapObjects#remove(int)
See https://libgdx.badlogicgames.com/ci/nightlies/docs/api/com/badlogic/gdx/maps/MapObjects.html
So I guess you will do something like this:
ArrayList<MapObject> objectsToRemove = new ArrayList<>();
for (MapObject object : mapLayer.getObjects()) {
if (object.getName().contains("removeMe")) // TODO
{
objectsToRemove.add(object);
}
}
for (MapObject mapObject : objectsToRemove) {
mapLayer.getObjects().remove(mapObject);
}

Sebastian
- 5,721
- 3
- 43
- 69