Repeating background in cocos2d has black edges!

I am trying to customize a tiled / repeating background for my iPhone application.

The code "works" in that the background repeats, as it should be, but I seem to have a black border around each repetition, and I don’t know why the image is exactly 200x200. Here is a screenshot of what it looks like with the code:

if ((self=[super init])) {
    CCSprite * bg = [CCSprite spriteWithFile:@"pattern11.jpg" rect:CGRectMake(0, 0, 1000, 520)];
    [bg setPosition:ccp(0, 0)];
    ccTexParams params = {GL_LINEAR,GL_LINEAR,GL_REPEAT,GL_REPEAT};
    [bg.texture setTexParameters:&params];
    [self addChild:bg z:0];
}

enter image description here

+5
source share
2 answers

Textures should always be in the hands of two ... for example, 16.32.64.128,256,512,1024.

Try resizing the image to 256x256 or 128x128.

+4
source

All Articles