Loading Tiled Maps from MonoGame.Extended XNB

I’ve heard many things about Tiled and decided to look into it. I used MonoGame.Extended’s very useful content processor for importing a TiledMap. It builds correctly, but I can’t actually load the map at runtime.

Here’s my code:

public TiledMap LoadMap(in string mapName)
{
    return LoadAsset<TiledMap>(mapName);
}

Here is my Content.mgcb file:
Imgur

Finally, here is the output when I make a build:
Imgur

My Content root directory is set to “Content/” and I am able to load everything else fine. I have confirmed that the file path to the .tmx file is correct. The .tmx, .tsx, and processed XNB file for the tile image are all in the same directory. The inner exception indicates it’s looking for a file named “BG2.xnb,” which would mean I have to process the .tsx file as a tileset, but there is no such option for any of the importers. Any ideas?

If you’re using the 1.1 NuGet packages I believe we didn’t have external Tilesets implemented.

In the Tiled Map Editor it used to default to embedding the tileset into the map. They’ve now changed this so you have to explicitly click a checkbox to embed the tileset.

Try embedding the tileset and see if that solves the problem.

I think we may have fixed this issue in the develop branch but it’s going to be a while before we release 2.0. If you like living on the edge you could always fork our repo and build from source.

1 Like

Thanks; embedding it worked!