Artefacts in Cocos2d

Working on the current project I came across a problem with cocos2d: for some reason an atlassprite is influenced by what is on the atlas next to it. As such, if you place two atlassprites right next to each other, artefacts can start to appear, lines which arn’t really there:

withart

Notice those thin white and black lines? It should actually look like this:

withoutart

There currently is no real solution. The common work around is to copy the correct color(s) to the borders of the sprite. mkatlas.pl, a script by Matthias Hoechsmann that comes with cocos2d, includes a simple algorithm which takes the corner color of the sprite and copies it into the borders. This solution however does not work if the edge of your sprite has varying colors.

To improve the work around I have modified the script to copy the edge of the sprite into the borders (when mkatlas is run with -p 2). This way the correct colors are now next to the actual sprite and the artefacts disappear.

The improved script is available here (scroll down for the newest version).

Thank you to Ricardo Quesada for correctly diagnosing the problem and Matthias Hoechsmann for the original mkatlas.pl script.

Posted in Project Kyoto. Tags: . RSS. Trackback.

One Response to “Artefacts in Cocos2d”

Leave a Reply