Search code examples
cocos2d-iphonecocos2d-x

possible having different color string in one CCLabelTTF?


I can use CCLabelTTF like this, (cocos2d-x v2.1.4)

CCLabelTTF* ableText = CCLabelTTF::create("hello red blue green", "Arial", 9);
ableText->setPosition(ccp(100, 100));
ableText->setAnchorPoint(ccp(0.5, 0.5));
ableText->setColor(ccc3(100, 100, 100));
ableText->setHorizontalAlignment(kCCTextAlignmentCenter);
this->addChild(ableText, 1);

But, I want to give different colors to the string.
"red" => red color
"blue" => blue color
"green" => green color

Is it possible using one CCLabelTTF?


Solution

  • No, you'll have to split up the string into individual labels per color.