Monogame + Tiled Map Editor Tilesheet problem

Hi,

First of all, sorry English is not my native language

I have some problem with Tiled Map Editor and Monogame.
I use TiledSharp to integrate my tiles into my project Monogame but the offset is not respected.

Here is Tiled Map Editor:

Now the TMX in Monogame:

And the final rendering:

I can not find the solution …

Any Idea ?

We can’t help you if you don’t share your code. TiledSharp only does importing so most likely this is a bug in your rendering code. There’s a MonoGame sample project for using TiledSharp which might help you out over here: https://github.com/Temeez/TiledSharp-MonoGame-Example

An alternative is to use MonoGame.Extended’s support for Tiled maps. It handles rendering for you. I think there’s a NuGet package specifically for the Tiled classes.

My code :

http://pastebin.com/raw/0TjMRtFz

Thanks for u help.

So, it’s better to use Monogame.Extended than TiledSharp?

int row = (int)Math.Floor((double)tileFrame / (double)tilesetTilesWide);
float y = (float)Math.Floor(i / (double)level.Width) * level.TileHeight;

You actually want integer division in these lines. So you can change these to

int row = tileFrame / tilesetTilesWide;
int y = i / level.Width * level.TileHeight;

It doesn’t look like that’s what causing the rendering issues though, but I haven’t tested so I might be wrong.

It’s a matter of preference. TiledSharp only handles importing while MonoGame.Extended handles rendering too.