TiledMap.Draw not respecting passed in "visibleRectangle"

Trying to draw my TiledMap using this:

tiledMap.Draw(spriteBatch, Camera.ViewPort);

where Camera.Viewport is the Rectangle defining the area of the map that should currently be visible to the player. However, the draw method always just draws the map from the top left tile, it does not draw the part of the map that the Rectangle defines. What am I missing here? Is this not what the argument “visibleRectangle” is for?

I’m using Monogame.Extended version 0.5.149

Hey @EvilRikard

Since this is a potential issue with the library, @Aurioch raised it on our github issues page.

The short answer is, a lot has changed since version 0.5.149. It’s probably best to try build from source or use a pre-release NuGet package

I’m not entirely certain what the problem is, or if it has been fixed but there’s been plenty of activity on the Tiled code recently.

First, thanks for your response, happy to get the attention :slight_smile:

Now, I don’t know if this affects anything but I’m an a MacBook using Xamarin Studio. And I added MonoGame.Extended as a NuGet package to my project and got version 0.5.149. When I do “Project->Update NuGet Packages” I get the feedback that all packages are up to date. Not sure what’s happening here if you say that “a lot has happened” since this version. Any chance that you can elaborate on this and help me understand how this is all working and what I need to do?

Whatever the reasons for my old version of the library was, I have now taken the developer’s branch instead and built it from scratch. Looking through the code it seems to me like now a Camera2D must be used to draw the TiledMap, is that correct or is there any other way to draw the TiledMap and make it respect a camera/viewpoint of some sort?

In the current version of the code the Tiled maps are rendered with the FullMapRenderer (we might rename this at some point).

The Draw method takes a viewMatrix.

Typically, you’d want to use the camera’s GetViewMatrix method to pass to the map renderer, although, you could create your own matrix if you want.