标签:
这里要注意.fnt文件可通过BMFont工具进行创建,该代码于init函数中:
auto label1 = Label::createWithSystemFont("Hello World1", "Arial", 24); label1->setPosition(Vec2(origin.x + visibleSize.width/2, origin.y + visibleSize.height - 100)); this->addChild(label1, 1); auto label2 = Label::createWithTTF("Hello World2", "fonts/Marker Felt.ttf", 24); label2->setPosition(Vec2(origin.x + visibleSize.width/2, origin.y + visibleSize.height - 200)); this->addChild(label2, 1); auto label3 = Label::createWithBMFont("fonts/t2.fnt", "Hello World3"); label3->setPosition(Vec2(origin.x + visibleSize.width/2, origin.y + visibleSize.height - 300)); this->addChild(label3, 1); TTFConfig ttfConfig("fonts/Marker Felt.ttf", 24, GlyphCollection::DYNAMIC); auto label4 = Label::createWithTTF(ttfConfig, "Hello World4"); label4->setPosition(Vec2(origin.x + visibleSize.width/2, origin.y + visibleSize.height - 400)); this->addChild(label4, 1); ttfConfig.outlineSize = 4; auto label5 = Label::createWithTTF(ttfConfig, "Hello World5"); label5->setPosition(Vec2(origin.x + visibleSize.width/2, origin.y + visibleSize.height - 500)); // Enable shadow for the label label5->enableShadow(Color4B(255,255,255,128), Size(4, -4)); label5->setColor(Color3B::RED); this->addChild(label5, 1);
运行结果如下:
标签:
原文地址:http://www.cnblogs.com/AmitX-moten/p/4200047.html