Sign in to follow this  
Followers 0
Inu_

Problem Tiling a Sprite

1 post in this topic

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_
0

Share this post


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

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0