I have several fullscreen (480x320) sprites positioned exactly next to each other. When the game scrolls horizontally over these sprites I get a flickering black vertical line between the sprites. I searched around on the forum and found several threads about similar problems. But nothing I have tried has fixed the issue.
I use regular sprites and not atlas sprites. I have set 2D projection. I have tried to add 0.5f to the position.
I'm using Cocos2d 0.8.2.
Flicker between sprites
(10 posts) (4 voices)-
Posted 2 years ago #
-
I'm sure you've seen MikeSz's thread:
http://www.cocos2d-iphone.org/forum/topic/2615so, why not use AtlasSprites? In the testing I did for that issue AtlasSprites performed much better than Sprites in terms of seamlessness.
How are you positioning the Sprites? Subpixel positions can cause artifacts, clamping to whole pixel locations works well but may be too jerky, you can experiment with clamping the x position to different intervals such as 0.5 or 0.2 pixels.
Posted 2 years ago # -
Yes, I've read that thread. My sprites are totally static, I only move the camera. I guess I should try AtlasSprites. I haven't given it much thought as my sprites are pretty big.
Posted 2 years ago # -
I just tried atlas sprites instead and as soon as I set it to setAliasTexParameters everything looked perfect. Adding 0.5f to the position is not needed.
Thanks for your help!
Posted 2 years ago # -
I now have the flicker problem again. It disappeard when I switched to AtlasSprite. But now I need to put multiple AtlasSprites next to each other but from different AtlasSpriteManagers. When I do that the flicker reappears.
Any ideas?
Posted 2 years ago # -
I use AtlasSprites and the flickering lines are pixels from the area around the sprite in the atlas. Does anyone know why it's inaccurate? The textures I use are 1024x1024 32bit png. The layer in which the sprites exist is also scaled between 0.25 and 2.0 by the user.
As a test I added a 1 pixel gap between the sprites. Depending on the scale of the layer I could see no gap or gap with background color or line with the atlas background/surrounding color. Sometimes both the bakground color and atlas background color.Posted 2 years ago # -
I have experienced the same issue with sprites and separate AtlasSpriteManagers next to each other. I didn't find a solution but I found a few work arounds that have worked very well for me.
1. Change the sprites that are next to each other to fade to transparent on the edges that touch. Put a background sprite in the middle under the 2 sprites with a similar texture. I used this for a repeating background and it worked great.
2. Create a background sprite that takes up the entire screen that never moves. Design the sprites that move to not cover the entire background. To simulate movement on the stationary background, put a moving semi-transparent sprite over it that moves with faded edges, same as above.
You can get some cool effects using this method combined with multiple layers of different speeds and textures.
Posted 2 years ago # -
Thanks for your ideas, I will try them. I came up with my own work around aswell. I made each sprite in the atlas larger than it needs be, so when it flickers with pixels outside of the sprite the colors are correct anyway.
Posted 2 years ago # -
did you come up with a solution that works for you?
i changed my sprite sheet that way that i have 1px spacing between the sprites but it still flickers and one sprite shows parts of another sprite (only sometimes) that is more than 1px away. really odd.Posted 2 years ago # -
ok apart from adding 1px space around the sprite i also increased the size of the rect accordingly which should explain why it was still flickering xD
With 1px additional space around the sprite which is not covered by the texture-rect it seems to be fine.
Posted 2 years ago #
Reply
You must log in to post.