예제 #1
0
void Label::disableEffect(LabelEffect effect)
{
    switch (effect)
    {
    case cocos2d::LabelEffect::NORMAL:
        break;
    case cocos2d::LabelEffect::OUTLINE:
        if (_currLabelEffect == LabelEffect::OUTLINE)
        {
            if (_currentLabelType == LabelType::TTF)
            {
                _fontConfig.outlineSize = 0;
                setTTFConfig(_fontConfig);
            }
            
            _currLabelEffect = LabelEffect::NORMAL;
            _contentDirty = true;
        }
        break;
    case cocos2d::LabelEffect::SHADOW:
        if (_shadowEnabled)
        {
            _shadowEnabled = false;
            if (_shadowNode)
            {
                Node::removeChild(_shadowNode, true);
                _shadowNode = nullptr;
            }
        }
        break;
    case cocos2d::LabelEffect::GLOW:
        if (_currLabelEffect == LabelEffect::GLOW)
        {
            _currLabelEffect = LabelEffect::NORMAL;
            updateShaderProgram();
        }
        break;
    case LabelEffect::ALL:
        {
            disableEffect(LabelEffect::SHADOW);
            disableEffect(LabelEffect::GLOW);
            disableEffect(LabelEffect::OUTLINE);
        }
        break;
    default:
        break;
    }
}
예제 #2
0
void Label::setLabelEffect(LabelEffect effect,const Color3B& effectColor)
{
    switch (effect)
    {
    case cocos2d::LabelEffect::NORMAL:
        disableEffect();
        break;
    case cocos2d::LabelEffect::OUTLINE:
        enableOutline(Color4B(effectColor));
        break;
    case cocos2d::LabelEffect::SHADOW:
        enableShadow(Color4B(effectColor));
        break;
    case cocos2d::LabelEffect::GLOW:
        enableGlow(Color4B(effectColor));
        break;
    default:
        break;
    }
}
예제 #3
0
void ManualCode::addCodeTexture(string text) const
{
    float h = LabelDimHeight(text.c_str(), "Helvetica", 20, codeView->getSize().width);
    if (h < codeView->getSize().height) {
        h = codeView->getSize().height;
    }
    auto label = Label::createWithSystemFont(text.c_str(), "Helvetica", 20);
    label->disableEffect();
    label->setColor(Color3B::BLACK);
    label->setDimensions(codeView->getSize().width, h);
    label->setAlignment(TextHAlignment::LEFT, TextVAlignment::TOP);
    label->setAnchorPoint(Point::ANCHOR_BOTTOM_LEFT);
    
    codeView->removeAllChildrenWithCleanup(true);
    codeView->setInnerContainerSize(label->getDimensions());
    codeView->setInertiaScrollEnabled(true);
    codeView->addChild(label);
    
    codeView->jumpToTop();
}
예제 #4
0
void Label::disableEffect()
{
    disableEffect(LabelEffect::GLOW);
    disableEffect(LabelEffect::OUTLINE);
    disableEffect(LabelEffect::SHADOW);
}