iphone - 如何在cocos2d中设置CCLabelTTF的背景颜色

标签 iphone ios4 cocos2d-iphone

我目前正在为我的游戏使用 Cocos2d FrameWork。我需要更改 CCLabelTTF 中的背景颜色。我知道如何设置字体颜色,有人可以告诉我如何更改 CCLabelTTF 对象的背景颜色。

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];

这是我添加标签的示例代码。有什么想法吗?

最佳答案

您无法设置 CCLabelTTF 的背景颜色。

你可以做的是在标签后面显示单色CCSprite,或者使用CCLayerColor在背景中与标签具有相同的宽度和高度。

关于iphone - 如何在cocos2d中设置CCLabelTTF的背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7928968/

相关文章:

ios - cocos2d v3.0 中 CCLabelTTF 的构造函数

xcode - cocos2d创建一个圆形并将其用作 Sprite

iphone - 应用内购买响应。产品为空

iphone - 父 View Controller 中是否有一个委托(delegate)在模态视图被关闭后被调用?

iOS 从另一个类访问 int

memory-management - Release Release UIWebView content from the memory,强制app释放内存

iphone - Objective C Iphone 开发距离公式

ios - 如何修复 Alamofire 库错误?

iphone - 向 UIButton 添加导出

iphone - iPhone应用程序会记录声音并保存这些声音