How to Fix Strange Lines in Cocos2D by using Extrude in Zwoptex

Ever since I started using Zwoptex, a sprite sheet packing tool, I started noticing these strange lines between my sprites in Cocos2D during gameplay. I had no idea why they would appear if the sprites had no immediate cut off on the boundaries.

I found an awesome tip in the following post, Strange lines appears during sprite movement, in the Cocos2D forums. Depending if the problem occurs due to the background or foreground, you either have to extrude or add padding to your sprites.

When you extrude, you simply repeat the same pixels around the tiles without adding them directly to the sprite. Extruding actually helped me fix my problem. Padding seems to just separate the sprites from each other. If you notice sprites leaking nearby sprites on the sprite sheet, padding should solve this problem.

After learning about this, I fired up Zwoptex, selected all my sprites, and added about 1px to the Extrude option.

After that, I started my game and was able to see that strange line effect gone!

If you use Texture Packer you have the same option.

Resource – Strange lines appears during sprite movement

Tags: , , , ,

  • http://www.spinxwebdesign.com/ Spinx Inc

    Nice information. Great tips and thanks for sharing. Zwoptex is really helpful to give more animated effects to sprite and can save your too much time.