Problems using Extended Tiled Map

Hi guys,

I’m trying to use MonoGame.Extended.Tiled in my project (Mac, vscode, source) but issuing the error below.

Argument 1: cannot convert from 'MonoGame.Extended.Tiled.TiledMap' to 'Microsoft.Xna.Framework.Matrix?' [rpg]

My csproj references.

<PackageReference Include="MonoGame.Framework.DesktopGL.Core" Version="3.8.*" />    
<PackageReference Include="MonoGame.Content.Builder" Version="3.7.*" />    
<PackageReference Include="MonoGame.Extended.Content.Pipeline" Version="3.7.0" />
<PackageReference Include="MonoGame.Extended.Tiled" Version="3.7.0" />      
<PackageReference Include="MonoGame.Extended" Version="3.7.0" />
<PackageReference Include="MonoGame.Extended.Graphics" Version="3.7.0" />

Libs:

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using MonoGame.Extended.Graphics;
using MonoGame.Extended.Tiled;
using MonoGame.Extended.Tiled.Renderers;

Code Vars:

   TiledMap myMap;
   TiledMapRenderer mapRenderer;

Code Initialize:

mapRenderer = new TiledMapRenderer(GraphicsDevice);

Code LoadContent

myMap = Content.Load<TiledMap>("Middsc/gameMap");

Code Draw:

mapRenderer.Draw(myMap);

I would appreciate if anyone could help me.

Best Regards,

Just had a look at the sources at the 3.7.0 branch and it appears as though your’re using an outdated syntax.
From the sources I was able to infer that you need to first call: mapRenderer.LoadMap(myMap); (probably in the Load). Then in the Update call: mapRenderer.Update(gameTime);, Finally in Draw call mapRenderer.Draw(); without any parameters, unless trying to apply a view matrix.
The reason why you were receiving the error was because the Draw method was expecting a Matrix

Source: https://github.com/craftworkgames/MonoGame.Extended/blob/v3.7.0/Source/MonoGame.Extended.Tiled/Renderers/TiledMapRenderer.cs

Disclaimer: I haven’t really used MonoGame.Extended

I can’t thank you enough. It worked!

The code.

Vars:

TiledMap myMap;
TiledMapRenderer mapRenderer;

Initialize:

mapRenderer = new TiledMapRenderer(GraphicsDevice);

LoadContent:

myMap = Content.Load<TiledMap>("Misc/gameMap");
mapRenderer.LoadMap(myMap);

Update:

mapRenderer.Update(gameTime);

Draw:

mapRenderer.Draw();