I’m using MonoGame 3.8.0.1641. I’m building a top-down dungeon crawler; nothing fancy. I have a top-down view of a dungeon corridor. At one spot, there are three doors leading in different directions on one tile. See image:
The problem is that the west door in the center doesn’t render. You can see on the other side of the tile; the east half of the door renders fine. And you can see west doors do normally render (e.g. the door to the far left).
I’m using the same sprite (the door sprite) in the same position and just rotating it 90° for each SpriteBatch Draw call.
If I turn off all the east doors, the west door renders fine (but then, of course, I don’t have any east doors).
I render the doors in this order:
- North door
- East door
- South door
- West door
If I change the order and render the east doors last, then they don’t show up!
The code for rendering the west door is below, but it’s similar to how they all are:
if ((tile & (uint)con.Tile.DoorWest) > 0)
{
// Weird thing I have to do because rotating the sprite moves it one block to the left
blockRect.X += blockRect.Width;
// rotate sprite and draw it
float rotation = (float)ConvertDegreesToRadians(90.0f);
_spriteBatch.Draw(_doorSprite, blockRect, srcRect, Color.White,
rotation, origin, SpriteEffects.None, 1.0);
}
The sprite itself is pretty simple. It’s a PNG with a transparent background. It’s just a few black lines and it’s the same size as a full tile:
I thought the transparent part of the tile might be drawing opaque, but that can’t be the case because then the north door would get cut off as well.
I tried lots of other things, like playing with opacity, z-order and whatnot, but nothing makes any difference. I tried a different sprite which has a magenta background instead. While the magenta renders as transparent like it should, it displays the same erroneous rendering.
Any ideas?