Collision Layer cannot be set invisible

Hey guys!

I’m currently programming a mobile game with libgdx and Tiled. Somehow, i cannot set the green collision layer invisible. I already tried clicking the eye button in the tiled editor as well as changing the tmx file.
This code line:

tiledMap.getLayers().get(index).setVisible(visible);

doesn’t work as well.

Here is a picture of the problem:

greenLines

much thanks in advance :slight_smile:

Max

Of course it may be that somebody here knows the answer, but this question is really specific to libgdx, so you’re more likely to find help by asking in the libgdx community.

Personally I saw that MapRenderer.render() is documented to render all layers of the map. But from the code you can see that it does try to skip non-visible layers:

You could probably use the MapRenderer.render override that takes a list of layers, and leave your collision layer out of that list, but I don’t see why the setVisible(false) would not work (you are passing in false, are you?).

Hey Bjorn,

thanks for your answer! I tried handing over the array, but it just worked for graphical layers. Same goes for setVisible(false)…
However, i think you were right about the questions connection to libgdx :slight_smile:
I searched the web and i think i found a video which describes the problem / solution.
(right now it’s too late for me to watch it entirely so i cant tell 100%)

In case you are interested or somebody else encounters the same problem:
At the beginning of the video the green lines are still there, later on they are gone but collision still works.

have a nice day and keep on the great work!

Ah, those green lines have nothing to do with your collision layer. That’s the debug draw of the physics engine, which you’ll have to disable somewhere else. Probably by just not calling render on some Box2DDebugRenderer you may have somewhere.