How to set background color in CCLabelTTF in cocos2d

I am currently using Cocos2d FrameWork for my game. I need to change the background color in CCLabelTTF.I know how to set the font color, can someone tell me how to change the background color of the CCLabelTTF object.

CCLabelTTF *nameLabel=[CCLabelTTF labelWithString:[NSString stringWithFormat:@"%@",[plyName objectAtIndex:i]] fontName:@"Arial" fontSize:20];
        nameLabel.position=ccp(100,y1);
        nameLabel.color=ccc3(245, 222, 179);
        [self addChild:nameLabel];

This is my sample code for adding a label. Any ideas?

+5
source share
1 answer

You cannot set the background color of CCLabelTTF.

What you can do is display a single color CCSprite behind the label or use CCLayerColor in the background with the same label width and height.

+19
source

All Articles