->setPosition(ccp(screenSize.width/2,screenSize.height/2)); this->addChild(bgSprite); //label的使用 CCLabelTTF * label = CCLabelTTF::create(“loading”,”Arial”,25); label->setPosition(ccp(100,150)); label->setAnchorPoint addChild(label); count = 1; return true; } void LoadingLayer::timeUpdate(float dt) { //拼接字符串 CCLabelTTF *label = (CCLabelTTF*)getChildByTag(100); const char * str = label->getString(); char newstr[128];
. // add a label shows "Hello World" // create and initialize a label CCLabelTTF* pLabel = CCLabelTTF * pLabel = CCLabelTTF::labelWithString(text.c_str(), "Arial", 24); 哈哈,我们的第一步尝试成功了,来看一下截图: ? * pLabel = CCLabelTTF::labelWithString(text.c_str(), "Arial", 24); 不幸的是以上方案失败了: ? * pLabel = CCLabelTTF::labelWithString(text.c_str(), "Arial", 24); 哈哈,这次我们成功了: ? * pLabel = CCLabelTTF::labelWithString(text.c_str(), "Arial", 24); 情况OK :) ?
CCSize winSize = CCDirector::sharedDirector()->getWinSize(); //设置ControlSwitch控件打开的文字No" CCLabelTTF * on = CCLabelTTF::create("ON", "Arial", 16); //设置ControlSwitch控件关闭时的文字"OFF" CCLabelTTF* off = CCLabelTTF::create("OFF", "Arial", 16); //设置ControlSwitch控件打开的文字的颜色 on->setColor(ccc3(0,
)选项中的,Image format,为RGBA4444,并选择Dithering为 抖动 + 通道(FloydSteinberg + Alpha); 其它特殊的文字,使用CCLabelBMFont、CCLabelTTF 也可以实现上述效果,但是CCLabelTTF效率很低一般都不会使用,下一篇将介绍CCLabelBMFont的相关工具(Hiero)及使用… 参考: cocos2d-x: CCLabelAtlas类 将一堆小图转化为
CCTableViewCell(); cell -> autorelease(); } cell -> removeAllChildrenWithCleanup(true); CCLabelTTF * label = CCLabelTTF::create(“abc”,”Arial”,24); label -> setPosition(ccp(150,30)); cell -> addChild
getContentSize().width; bg->setScale(scale); char chLetter[2]; sprintf(chLetter,"%c",l[0] - 32); CCLabelTTF * letter = CCLabelTTF::create(chLetter,"Arial",75 * scale); letter->setColor(ccWHITE); tile->addChild getContentSize().width; bg->setScale(scale); char chLetter[2]; sprintf(chLetter,"%c",l[0] - 32); /* CCLabelTTF * letter = CCLabelTTF::create(chLetter,"Arial",78 * scale); letter->setColor(ccWHITE); tile->addChild
21 } 函数的使用方法如下: 1 //在场景中加入中文标签 2 std::string hello = "不如跳舞"; 3 GBKToUTF8(hello,"gb2312","utf-8"); 4 CCLabelTTF *label1 = CCLabelTTF::create(hello.c_str(),"Arial",20); 5 label->setPosition(320,250); 6 this->addChild
CCMenuItem *resumeItem; @property CCMenuItem *endItem; @property CCMenuItem *transitItem; @property CCLabelTTF setIsEnabled:NO]; [_helpItem setIsEnabled:NO]; //set the time shower _timeShow = [[CCLabelTTF
scene = CCScene:create() --创建一个层 local layer = CCLayer:create() --创建一个文本 local label = CCLabelTTF