Jump to content

  • Log In with Google      Sign In   
  • Create Account


Problem Tiling a Sprite


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Inu_   Members   -  Reputation: 263

Like
0Likes
Like

Posted 07 December 2012 - 05:29 PM

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:

tilingsprite.png


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

  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();

Edited by Inu_, 07 December 2012 - 06:00 PM.


Sponsor:

#2 phil_t   Crossbones+   -  Reputation: 3229

Like
2Likes
Like

Posted 07 December 2012 - 10:27 PM

The default SamplerState for SpriteBatch is LinearClamp. You want LinearWrap

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




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS