1

I'm trying to retrieve an object layer named "collisions", I'm using this code;

MapObjects mapObjects = tiledMap.getLayers().get("collisions").getObjects();

But I get a null exception error.

If I try to use .get(index)

MapObjects mapObjects = tiledMap.getLayers().get(4).getObjects();

I get an index out of bounds error instead, even though I have 5 layers in my map, 2 image layers, 2 tile layers and the collisions layer.

Exception in thread "LWJGL Application" java.lang.IndexOutOfBoundsException: index can't be >= size: 4 >= 4

I've looked at the libGDX docs and this seems to be the right way to get the map objects, so I'm confused as to what I'm doing wrong...

0 Answers0