SFML community forums
Help => Graphics => Topic started by: bobblehat on July 09, 2013, 02:14:59 am
-
So, I've been working on a simple tile engine for a 2D platformer today. There's an odd issue I keep having.
Essentially my program renders a subsection of a spritesheet as a texture for each tile, by putting them into sprites and then iterating over a collection of sprites. I then move around the map using sf::View.
However, at no regular interval but frequent enough I have this happen:
http://imgur.com/K8vPPZd
This is a screenshot with setSmooth enabled for the tileTexture to show what I mean (I understand these artifacts with this enabled - some blurring between tiles of the spritesheet would be inevitable) -- but the problem is that it happens without it.
My view is the same size as the screen resolution, but centered on the ball sprite.
I'm assuming I can get around this by using a RenderTexture to draw the level into memory, and redrawing that as a single texture/sprite every frame, but it seems strange as to why this is happening.
It just crops up for a single frame, and then disappears.
Any help would be greatly appreciated.
-
Start by trying this solution : http://en.sfml-dev.org/forums/index.php?topic=11971.msg83200;topicseen#msg83200
-
The logic in that post does make sense - I'll have to convert to vertices instead.
Is there any reason Sprites don't take a FloatRect in their constructor, or automatically account for this? The comments in the code state that the IntRect in the constructor is to only show a specific part of the texture, which is exactly what I'm trying to do -- it just seems slightly silly that more pixels get displayed than I need, and a bit inconsistently.
-
You should make sure that your view position are integers and since this can still lead to problems, I'd add a 1px wide border, only where the color should keep going, around the textures you're using.
It's a known issue with SFML and there hasn't really been a clean solution yet (that I know of).