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

Method Label

core/2d/Label.cpp:498–555  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

496}
497
498Label::Label(TextHAlignment hAlignment /* = TextHAlignment::LEFT */,
499 TextVAlignment vAlignment /* = TextVAlignment::TOP */)
500 : _textSprite(nullptr)
501 , _shadowNode(nullptr)
502 , _fontAtlas(nullptr)
503 , _reusedLetter(nullptr)
504 , _horizontalKernings(nullptr)
505 , _boldEnabled(false)
506 , _lineDrawNode(nullptr)
507 , _strikethroughEnabled(false)
508 , _underlineEnabled(false)
509{
510 setAnchorPoint(Vec2::ANCHOR_MIDDLE);
511 reset();
512 _hAlignment = hAlignment;
513 _vAlignment = vAlignment;
514
515#if AX_LABEL_DEBUG_DRAW
516 _debugDrawNode = DrawNode::create();
517 AX_SAFE_RETAIN(_debugDrawNode);
518#endif
519
520 _purgeTextureListener = EventListenerCustom::create(FontAtlas::CMD_PURGE_FONTATLAS, [this](EventCustom* event) {
521 if (_fontAtlas && _currentLabelType == LabelType::TTF && event->getUserData() == _fontAtlas)
522 {
523 for (auto&& it : _letters)
524 {
525 it.second->setTexture(nullptr);
526 }
527 _batchNodes.clear();
528 _batchCommands.clear();
529
530 if (_fontAtlas)
531 {
532 FontAtlasCache::releaseFontAtlas(_fontAtlas);
533 }
534 }
535 });
536 _eventDispatcher->addEventListenerWithFixedPriority(_purgeTextureListener, 1);
537
538 _resetTextureListener = EventListenerCustom::create(FontAtlas::CMD_RESET_FONTATLAS, [this](EventCustom* event) {
539 if (_fontAtlas && _currentLabelType == LabelType::TTF && event->getUserData() == _fontAtlas)
540 {
541 _fontAtlas = nullptr;
542 auto lineHeight = _lineHeight;
543 this->setTTFConfig(_fontConfig);
544 if (_currentLabelType != LabelType::STRING_TEXTURE)
545 {
546 setLineHeight(lineHeight);
547 }
548 for (auto&& it : _letters)
549 {
550 getLetter(it.first);
551 }
552 }
553 });
554 _eventDispatcher->addEventListenerWithFixedPriority(_resetTextureListener, 2);
555}

Callers

nothing calls this directly

Calls 8

setTTFConfigMethod · 0.95
createFunction · 0.85
setAnchorPointFunction · 0.50
resetFunction · 0.50
getUserDataMethod · 0.45
setTextureMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected