CCLabelTTF:cocos文本设置
设备/引擎:Mac(11.6)/cocos
开发工具:Android studio(4.1.2)
开发语言:c++
开发需求:cocos文本设置
1.创建文本,代码如下:
CCLabelTTF* firstTalk = CCLabelTTF::create("aaaaa!","Arial", 30);
2.文本换行:\n
CCLabelTTF* firstTalk = CCLabelTTF::create("aaaaa! \n bbbb!","Arial", 30);
3.文本位置:
firstTalk->setPosition(ccp(50,180));
4.文本对齐方式
firstTalk->setHorizontalAlignment(kCCTextAlignmentLeft);
firstTalk->setHorizontalAlignment(kCCTextAlignmentRight);
firstTalk->setHorizontalAlignment(kCCTextAlignmentCenter);
5.描边
CCLabelTTF* textAddOutline(float lineWidth);
CCLabelTTF* firstTalk = CCLabelTTF::textAddOutline("aaaaa!","Arial", ccBLACK,1);
6.阴影
CCLabelTTF* textAddShadow(float shadowOpacity);
CCLabelTTF* firstTalk = CCLabelTTF::textAddShadow("aaaaa!","Arial", ccBLACK,3,100);
7.文本锚点位置: 控制文本对齐方式,注意与上面的左右对齐不同。
firstTalk->setAnchorPoint(ccp(0,0.5));
……
有关cocos-UI控件涉及到问题暂时整理了这些,希望能给大家带来帮助!!! 有什么其它问题及疑惑可以评论私信探讨一下~
|