Tile rotation not working fully with TiledSharp

Hey everyone, I’m using TiledSharp to load TMX maps that I made in Tiled.
My issue is, rotation doesn’t work properly. I am using the FlipHorizontally and FlipVertically values that are found in TmxLayerTiles. This is how I’m using it:
https://hst.sh/uwolacayib.cpp
Now this seems to work sometimes, Other times not so much. This is how a map should look:

Only 4 distinct tiles are being used. The 4 tiles in the bottom right are just one tile rotated multiple tiles.
The 3 tiles on the top are un-rotated, While the three in the bottom left are the same tiles, just rotated to make it vertical.
In the game, this is how it looks:
image So the bottom right tiles are rotating but the left ones don’t? I’m using only one tileset, and I’m loading it in as an image. Checking the GID Values for the tiles gives a weird result, Every value is +1 more than the value of the gid in the tileset.
The largest gid I’m using should be 289, but by debugging I notice every tile has a gid +1 more than the tileset value, So the 289 tile gives a gid of 290 but looks like the 289.

Hey @Locipro, Welcome to the Community,

I guess this got overlooked…

Perhaps reset your rotation values each line…

I guess the count thing uses an array? so, it would begin at 0, and not 1, so always subtract 1 from the max value…

Not looked at code as it is somewhere I do not know so… try pasting it here with the code button…

Good Luck!

Happy Coding!

Hello! Sorry my response is so late, I only got the notification today.
In my original tries to fix this I used SpriteEffects to flip the tiles, But for some reason I didn’t think to just use radian rotation and the default rotation parameter. This is what worked for me:

tileRot = 0;
if (currentLayer.Tiles[j].DiagonalFlip) 
{
    tileRot = tileRot + (float)(90 * Math.PI / 180);
}
if (currentLayer.Tiles[j].VerticalFlip) 
{
    tileRot = tileRot + (float)(180 * Math.PI / 180);
}
1 Like