3

I made my project to show simple texture by using CCSprite.

But I found that the texture contains some tiny noise , black pixel bug.

I divided the png file into small piece by using code. And add it to the mainview.

Not all of them have noise, But some of them have it.

I can't know the reason.

Please send your opinion.

CCSprite *sprite = [[CCSprite spriteWithFile:[NSString stringWithUTF8String:name] rect:CGRectMake(startx, starty, w, h)] retain];

float drawX = x, drawY = y;

CGSize size = [sprite contentSize];

int nWidth = size.width;

int nHeight = size.height;

nWidth *= scale;

nHeight *= scale;

drawX = drawX + nWidth/2;

drawY = drawY - nHeight/2;

ConvertCoordf(&drawX, &drawY);

drawY -= nHeight;

[sprite setScale:scale];

[sprite setPosition:ccp(drawX, drawY)];

[_mainLayer addChild:sprite];

[sprite release];    
CodeSmile
  • 64,284
  • 20
  • 132
  • 217
bTagTiger
  • 1,261
  • 5
  • 23
  • 38
  • 2
    a working solution to this problem is to use TexturePacker – CodeSmile Oct 23 '11 at 21:53
  • Can you post your png? I would like to test this a bit.. this could be some kind of problem on your image encoding or on the current opengl texture context... – Andres C Mar 26 '12 at 18:13

1 Answers1

0

For every image, it has some noise pixel around it (Only 1 pixel). For example, if you want to include an image with 30px*30px, you'd better make it into a 31px*31px image and put your image in the middle of it.In other words, surround your image with 1px.

Ringo_D
  • 342
  • 1
  • 2
  • 12