Tiled display and hide layer

How can i display layer when an event is handled and hide it when an other event is handled with Monogame Extended.

Thanks in advance

The API doesn’t really exist right now for this. I’m working on it this week to draw specific layers instead of the whole map at once.

1 Like

I dont use extended, but I am working on a game with layers of tile maps…

So if you have your layers in a list like I do (to update and draw them) you can simply have a second list of indexes to draw, ( separate from the list of layers that exist) and then use a for loop on this index list, to draw every layer represented by each index number.

Then you just add or remove index numbers from the to_draw list, and layers pop in and out of invisibility.

If you mean indexes as tile indexes, we don’t use SpriteBatch as a renderer.

I meant you have all your layers in a list, and then you have a list of ints representing the index numbers of the layers you want to draw from the layer list… So you could have 10 layers in your current level or screen area, but only have 3 index numbers in your draw list… 7 layers would not be drawn, but they would still exist.

But if extended doesn’t have a mechanism like a draw cycle for each item on a list, then yeah, I can do nothing to help…

Again, it’s slightly more involved because the tiled map renderer uses GraphicsDevice.Draw...() method calls directly instead of a SpriteBatch to render the tiles.

yeah, and I didn’t even know THAT much about extended. Sorry I couldn’t help :slight_smile:

Thank you for your reply.

I found a temporary solution but I think it is not clean.

the solution is to load the same tiled map any time you want to change properties of the layer and set some properties (ex : layer.IsVisible = false) and use the swap function of FullMapRendererFullMapRenderer to st the modification.

  1. _mapRenderer = new FullMapRenderer(GraphicsDevice, new MapRendererConfig {CacheRenderDetails = false})
  2. tiledMap = Content.Load()
    3.layer = _tiledMap.GetLayer ()
    4.layer.IsVisible = false

I apologize for my English

Could you maybe have the settings pre-loaded, and just switch between them, or swap them as needed?

Would take up more memory, but wouldn’t have the loading at run-time problems…

Can you not implement an Array based loader/renderer?

I re-wrote the renderer from scratch. (It’s not merged yet, still need to fix animating tiles and some other bugs, but static tiles do work.) The new API is to be used like this:

            // I am hoping that we can later create an OrthographicCamera class which is responsible for calculating the view AND projection matrix.
            var viewMatrix = _camera.GetViewMatrix();
            var projectionMatrix = Matrix.CreateOrthographicOffCenter(0, GraphicsDevice.Viewport.Width,
                GraphicsDevice.Viewport.Height, 0, 0f, -1f);

            _mapRenderer.Begin(ref viewMatrix, ref projectionMatrix);

            foreach (var layer in _mapRenderer.Map.Layers)


@Fadel_Fadel Let me know if this API is not going to work for you and we can talk about it.