| 3495 | /// |
| 3496 | |
| 3497 | LabelBold::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 | |
| 3537 | std::string LabelBold::title() const |
| 3538 | { |
nothing calls this directly
no test coverage detected