I have a bunch of sprites that share the same texture atlas, like this
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"Atlas.plist"];
CCSprite *sprite1 = [CCSprite spriteWithSpriteFrameName:@"Star1.png"];
CCSprite *sprite2 = [CCSprite spriteWithSpriteFrameName:@"Star2.png"];
[self addChild:sprite1];
[self addChild:sprite2];
And a bunch of bitmap font labels that use the same FNT font, like this
CCLabelBMFont *label1 = [CCLabelBMFont labelWithString:@"label1" fntFile:@"font.fnt"];
CCLabelBMFont * label2 = [CCLabelBMFont labelWithString:@"label2” fntFile:@"font.fnt"];
[self addChild: label1];
[self addChild: label2];
All of them are in the same layer
I wonder if packing the font.png
file (used by font.fnt
) into the texture atlas, say with a tool like texture packer, would cause cocos2d to use the same texture atlas to draw both labels and sprites