XNA 2D Spritesheet drawing rendering problem
Posted
by
user24092
on Game Development
See other posts from Game Development
or by user24092
Published on 2012-12-18T00:40:51Z
Indexed on
2012/12/18
5:13 UTC
Read the original article
Hit count: 254
I'm making a tile-based game, using one spritesheet containing all tile graphics. Each tile has a size of 32x32 pixels.
The main problem is: when I draw the tile to the screen, if the tile position x and y are not rounded or if scale is activated in spriteBatch.Draw() method (scale != 1.0f), I get some lines of adjacent tiles on the spritesheet into the current tile drawed.
I already tried setting SamplerState to PointClamp, removing AntiAlias, but still doesn't work.
Here I'll show images of some tests that I made, with a test sprite sheet that I've created (I made a 9x9 spritesheet, with each sprite of size 32x32 containing a unique solid color).
Tests: http://img6.imageshack.us/img6/5946/testsqj.png
SpriteSheet used: http://imageshack.us/a/img821/1341/tilesm.png
Already tried to remove anti-alias, set PointClamp as sampler state, but still getting this issue, XNA keeps drawing part of the adjacent pixels of the texture on the screen.
What I want is to get the correct area of the tilesheet texture (as seen in the first test, that gets just the yellow pixels).
My question is: Is there any way that I can fix this, WITHOUT adding tile spacing or any other modification involving the tilesheet?
Maybe disabling a texture filtering that is done by XNA, or something like that.
© Game Development or respective owner