I'm testing a theory on iPhone right now, and I'd love feedback from iPad dev's too (since I haven't got the iPad sdk going yet).
What I thought might help is to give GL more triangles per quad to reduce the number of pixels affected by any given tri. Play the the pxPerTile value as a larger value will result in fewer triangles. 32x32 seems ok for iPhone but maybe overkill for iPad so try 64x64 and 128x128 too.
Here's the code:
#import "CCBackgroundSprite.h"
...
CCBackgroundSprite *aSprite = [CCBackgroundSprite spriteWithFile:@"YourFullScreenImage.png"];
[self addChild:aSprite];
Save this to CCBackgroundSprite.h
#import "CCSpriteSheet.h"
@interface CCBackgroundSprite : CCSpriteSheet
{
}
+ (id) spriteWithFile:(NSString*)filename;
- (id) initWithFile:(NSString *)filename;
@end
Save this to CCBackgroundSprite.m
@implementation CCBackgroundSprite
+(id) spriteWithFile:(NSString*)filename
{
return [[[self alloc] initWithFile:filename] autorelease];
}
- (id) initWithFile:(NSString *)filename
{
CCTexture2D *texture = [[CCTextureCache sharedTextureCache] addImage:filename];
return [self initWithTexture:texture capacity:1];
}
-(id)initWithTexture:(CCTexture2D *)texture capacity:(NSUInteger)capacity
{
CGSize winSize = [[CCDirector sharedDirector] winSize];
NSUInteger pxPerTile = 32;
NSUInteger numRows = (int)ceilf(winSize.height)/pxPerTile;
NSUInteger numCols = (int)ceilf(winSize.width)/pxPerTile;
NSUInteger numTiles = numRows * numCols;
if( (self=[super initWithTexture:texture capacity:numTiles])) {
[self setContentSize:winSize];
self.anchorPoint = CGPointZero;
self.position = CGPointZero;
CGRect texRect = CGRectMake(0, 0, pxPerTile, pxPerTile);
CGPoint tilePos = ccp(0, winSize.height-pxPerTile);
for(uint i=1; i<=numTiles; i++){
CCSprite *aTile = [[CCSprite alloc] initWithTexture:textureAtlas_.texture rect:texRect];
aTile.anchorPoint = CGPointZero;
aTile.position = tilePos;
[self addChild:aTile];
[aTile release];
texRect.origin.x += pxPerTile;
tilePos.x += pxPerTile;
if(i%numCols == 0){
texRect.origin.x = 0;
texRect.origin.y += pxPerTile;
tilePos.x = 0;
tilePos.y -= pxPerTile;
}
}
}
return self;
}
@end