Skip to content

Instantly share code, notes, and snippets.

@xkyii
Last active December 17, 2015 10:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xkyii/5597451 to your computer and use it in GitHub Desktop.
Save xkyii/5597451 to your computer and use it in GitHub Desktop.
cocos2dx相关片段
// 使用CCLabelBMFont创建文字
// arial16.fnt可以在cocos2d-x包里找到
CCLabelBMFont* label = CCLabelBMFont::labelWithString("Hello World", "arial16.fnt");
label->setPosition(ccp(320, 480));
label->setScale(5);
addChild(label);
// 为每个单独的字设定颜色
for (int i=0; i<label->getChildrenCount(); i++)
{
CCSprite* sub = (CCSprite*)label->getChildByTag(i);
sub->setColor(ccc3(CCRANDOM_0_1()*255,CCRANDOM_0_1()*255,CCRANDOM_0_1()*255));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment