| 3443 | } |
| 3444 | |
| 3445 | LabelItalics::LabelItalics() |
| 3446 | { |
| 3447 | auto s = Director::getInstance()->getWinSize(); |
| 3448 | |
| 3449 | // LabelBMFont |
| 3450 | auto label1 = |
| 3451 | Label::createWithBMFont("fonts/bitmapFontTest2.fnt", "hello non-italics", TextHAlignment::CENTER, s.width); |
| 3452 | addChild(label1, 0, kTagBitmapAtlas1); |
| 3453 | label1->setPosition(Vec2(s.width / 2, s.height * 4 / 6)); |
| 3454 | // you can enable italics by calling this method |
| 3455 | |
| 3456 | _label1a = Label::createWithBMFont("fonts/bitmapFontTest2.fnt", "hello italics", TextHAlignment::CENTER, s.width); |
| 3457 | addChild(_label1a, 0, kTagBitmapAtlas1); |
| 3458 | _label1a->setPosition(Vec2(s.width / 2, s.height * 3 / 6)); |
| 3459 | // you can enable italics by calling this method |
| 3460 | _label1a->enableItalics(); |
| 3461 | |
| 3462 | // LabelTTF |
| 3463 | TTFConfig ttfConfig("fonts/arial.ttf", 24); |
| 3464 | auto label2 = Label::createWithTTF(ttfConfig, "hello non-italics", TextHAlignment::CENTER, s.width); |
| 3465 | addChild(label2, 0, kTagBitmapAtlas2); |
| 3466 | label2->setPosition(Vec2(s.width / 2, s.height * 2 / 6)); |
| 3467 | |
| 3468 | // or by setting the italics parameter on TTFConfig |
| 3469 | ttfConfig.italics = true; |
| 3470 | _label2a = Label::createWithTTF(ttfConfig, "hello italics", TextHAlignment::CENTER, s.width); |
| 3471 | addChild(_label2a, 0, kTagBitmapAtlas2); |
| 3472 | _label2a->setPosition(Vec2(s.width / 2, s.height * 1 / 6)); |
| 3473 | |
| 3474 | auto menuItem = MenuItemFont::create("disable italics", [&](ax::Object* sender) { |
| 3475 | _label2a->disableEffect(LabelEffect::ITALICS); |
| 3476 | _label1a->disableEffect(LabelEffect::ITALICS); |
| 3477 | }); |
| 3478 | menuItem->setFontSizeObj(12); |
| 3479 | auto menu = Menu::createWithItem(menuItem); |
| 3480 | addChild(menu); |
| 3481 | auto winSize = Director::getInstance()->getWinSize(); |
| 3482 | menu->setPosition(winSize.width * 0.9, winSize.height * 0.25f); |
| 3483 | } |
| 3484 | |
| 3485 | std::string LabelItalics::title() const |
| 3486 | { |
nothing calls this directly
no test coverage detected