I’m using the current release of monogame (3.4.0) and I experience an unexpected behaviour trying to tile sprites using the SpriteBatch. I’m following the original XNA-tutorial and expect that my texture is repeated like shown on the linked page. However, this is not the case:
Well, it works well (it’s linear).
To get the tiling effect you should draw your texture with this function: spriteBatch.Draw(spriteTexture, Vector2.Zero, destRect, color, 0, Vector2.Zero, 1, SpriteEffects.None, 0);
as it’s in the tutorial you’re using.
Source rectangle is what makes it tileable
A rectangle that specifies (in texels) the source texels from a texture. Use
null to draw the entire texture.
So if your source rectangle is bigger than the size of your texture, you get the tiling effect.
That’s some weird behaviour, imo … How can I combine this with tilesets? If I have hundreds of different tiles on one texture, I’d be using the source rectangle to select one specific tile from the tileset, but I can’t do that when I need the source rectangle to be bigger than the texture.
Texture wrapping generally doesn’t work with tilesets (although you can with some shader based wrapping). Usually you just render the tile multiple times to get the effect of wrapping.