MCPcopy Create free account
hub / github.com/axmolengine/axmol / LabelBold

Method LabelBold

tests/cpp-tests/Source/LabelTest/LabelTest.cpp:3497–3535  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3495///
3496
3497LabelBold::LabelBold()
3498{
3499 auto s = Director::getInstance()->getWinSize();
3500
3501 // LabelBMFont
3502 auto label1 =
3503 Label::createWithBMFont("fonts/bitmapFontTest2.fnt", "hello non-bold", TextHAlignment::CENTER, s.width);
3504 addChild(label1, 0, kTagBitmapAtlas1);
3505 label1->setPosition(Vec2(s.width / 2, s.height * 4 / 6));
3506 // you can enable italics by calling this method
3507
3508 _label1a = Label::createWithBMFont("fonts/bitmapFontTest2.fnt", "hello bold", TextHAlignment::CENTER, s.width);
3509 addChild(_label1a, 0, kTagBitmapAtlas1);
3510 _label1a->setPosition(Vec2(s.width / 2, s.height * 3 / 6));
3511 // you can enable italics by calling this method
3512 _label1a->enableBold();
3513
3514 // LabelTTF
3515 TTFConfig ttfConfig("fonts/arial.ttf", 24);
3516 auto label2 = Label::createWithTTF(ttfConfig, "hello non-bold", TextHAlignment::CENTER, s.width);
3517 addChild(label2, 0, kTagBitmapAtlas2);
3518 label2->setPosition(Vec2(s.width / 2, s.height * 2 / 6));
3519
3520 // or by setting the italics parameter on TTFConfig
3521 ttfConfig.bold = true;
3522 _label2a = Label::createWithTTF(ttfConfig, "hello bold", TextHAlignment::CENTER, s.width);
3523 addChild(_label2a, 0, kTagBitmapAtlas2);
3524 _label2a->setPosition(Vec2(s.width / 2, s.height * 1 / 6));
3525
3526 auto menuItem = MenuItemFont::create("disable bold", [&](ax::Object* sender) {
3527 _label2a->disableEffect(LabelEffect::BOLD);
3528 _label1a->disableEffect(LabelEffect::BOLD);
3529 });
3530 menuItem->setFontSizeObj(12);
3531 auto menu = Menu::createWithItem(menuItem);
3532 addChild(menu);
3533 auto winSize = Director::getInstance()->getWinSize();
3534 menu->setPosition(winSize.width * 0.9, winSize.height * 0.25f);
3535}
3536
3537std::string LabelBold::title() const
3538{

Callers

nothing calls this directly

Calls 7

getInstanceFunction · 0.85
createFunction · 0.85
enableBoldMethod · 0.80
setFontSizeObjMethod · 0.80
Vec2Function · 0.50
setPositionMethod · 0.45
disableEffectMethod · 0.45

Tested by

no test coverage detected