I'm using the Cocosbutton class to create a button which is added to the scene. This creates a CCSprite which is added to a CCMenuItem inside a CCMenu:
@interface CocosButtonItem : CCMenuItem {
...
In the init method, the background is added:
UIImage *bgImage = [UIImage imageWithContentsOfFile:@"buttonback.png"],
back = [CCSprite spriteWithCGImage:bgImage.CGImage key:@"bgimage"];
back.anchorPoint = ccp(0,0);
self.contentSize = back.contentSize;
CCLayerColor *bgFill = [CCLayerColor layerWithColor:ccc4(255.0, 255.0, 255.0, 255.0)];
bgFill.contentSize = self.contentSize;
bgFill.position = ccp(0,0);
[self addChild:bgFill];
back.color = ccc3(255,255,255);
[self addChild:back]; // without this, I just get a whit layer (as intended)
Once I add that final line to add the sprite to the CCMenuItem, I get a black background (see screenshot). The source for the CCSprite background image is an 8bit .png with transparency, and I can't figure out why I'm seeing this black background.