• Advertisement
Sign in to follow this  

Problem Tiling a Sprite

This topic is 1869 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have na 32x32 sprite that is going to be the Grass/ground of my game, and I am trying to make it fill the entire screen, but the image actualy becomes all distorced.

Here is a picture of the problem:

[attachment=12654:tilingsprite.png]


And here is the Draw code(using XNA 4.0):

[CODE]
spriteBatch.Begin(SpriteSortMode.BackToFront,
BlendState.AlphaBlend,
null,
null,
null,
null);
GraphicsDevice.SamplerStates[0] = SamplerState.LinearWrap;
Rectangle source = new Rectangle(0, 0, 500, 500);
spriteBatch.Draw(spritetest, Vector2.Zero ,source, Color.White, 0, Vector2.Zero,1.0f, SpriteEffects.None, 0.5f);
spriteBatch.End();
[/CODE] Edited by Inu_

Share this post


Link to post
Share on other sites
Advertisement
The default SamplerState for SpriteBatch is Linear[b]Clamp[/b]. You want LinearWrap

Pass SamplerState.LinearWrap for the 3rd parameter to SpriteBatch.Begin.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement