3、Cocos2d-X 游戏编程之------设置字体

来源:互联网 发布:matlab矩阵添加一行 编辑:程序博客网 时间:2024/06/15 19:43


3、设置字体

boolHelloWorld::init()

{

if (!CCLayer::init() )

{

 return false; 

}

//------CCLabelTTF

CCLabelTTF*pLabel = CCLabelTTF::create("CCLabelTTF-Thonburi","Thonburi", 24);

pLabel->setPosition(ccp(170,280) );

 this->addChild(pLabel);

CCLabelTTF*pLabel2 = CCLabelTTF::create();

//设置字体大小

pLabel2->setFontSize(20);

   

//设置字符串

   

pLabel2->setString("CCLabelTTF-Helvetica");

   

pLabel2->setPosition(ccp(170,250) );

   

this->addChild(pLabel2);

   

//------CCLabelAtlas

   

CCLabelAtlas*label = CCLabelAtlas::create("Atlas-823", "testfont.png",48, 64, ' ');

   

label->setPosition(ccp(0,190));

   

addChild(label);

   

//设置字体颜色

   

label->setColor(ccc3(255,0, 0));

   

   

CCLabelAtlas*label2 = CCLabelAtlas::create("LabelAtlas","testfont.plist");

   

label2->setPosition(ccp(0,140));

   addChild(label2);

 

//------CCLabelBMFont

 CCLabelBMFont* labelBM = CCLabelBMFont::create("Himi站立", "testChinese.fnt");

 labelBM->setPosition(ccp(180,100));

 addChild(labelBM);

return true;

}
0 0
原创粉丝点击