Last active
December 17, 2015 10:49
-
-
Save xkyii/5597451 to your computer and use it in GitHub Desktop.
cocos2dx相关片段
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 使用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