学了iphone,开发又开始学cocos2d-x觉2dx还是蛮好用的-----添加文字

我觉得cocos2d-x跟cocos2d很像的

添加字体:


         CCSize size = CCDirector::sharedDirector()->getWinSize();
CCSize blockSize = CCSizeMake(size.width, 200);
  CCLabelTTF* pLabel1 = CCLabelTTF::create("backCallback", blockSize, kCCTextAlignmentRight, kCCVerticalTextAlignmentTop, "Arial", 24);//内容,字体框大小,居右,靠上,字体,大小
CCLayerColor *leftColor = CCLayerColor::create(ccc4(100, 100, 100, 0), blockSize.width, blockSize.height);//背景层
 leftColor->ignoreAnchorPointForPosition(false);
 pLabel1->setPosition(ccp(100,size.height/2));
 leftColor->setPosition(pLabel1->getPosition());
 this->addChild(leftColor, 0);
 this->addChild(pLabel1, 0, kTagLabel1);


你可能感兴趣的:(学了iphone,开发又开始学cocos2d-x觉2dx还是蛮好用的-----添加文字)