diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index 0b7a5f6dd5..5147ba998d 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -457,6 +457,17 @@ void Label::setFontDefinition(const FontDefinition& textDefinition) { reset(); _fontDefinition = textDefinition; +#if (CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID) && (CC_TARGET_PLATFORM != CC_PLATFORM_IOS) + setColor(_fontDefinition._fontFillColor); + _fontDefinition._fontFillColor = Color3B::WHITE; +#else + if ( !textDefinition._shadow._shadowEnabled && !textDefinition._stroke._strokeEnabled) + { + setColor(_fontDefinition._fontFillColor); + _fontDefinition._fontFillColor = Color3B::WHITE; + } +#endif + _fontName = textDefinition._fontName; _fontSize = textDefinition._fontSize; _contentDirty = true; @@ -1150,34 +1161,28 @@ void Label::setOpacityModifyRGB(bool isOpacityModifyRGB) _reusedLetter->setOpacityModifyRGB(true); } -void Label::setColor(const Color3B& color) +void Label::updateDisplayedColor(const Color3B& parentColor) { - _fontDefinition._fontFillColor = color; + _displayedColor.r = _realColor.r * parentColor.r/255.0; + _displayedColor.g = _realColor.g * parentColor.g/255.0; + _displayedColor.b = _realColor.b * parentColor.b/255.0; + updateColor(); + if (_textSprite) { - updateContent(); + _textSprite->updateDisplayedColor(_displayedColor); } - if (_reusedLetter) - { - _reusedLetter->setColor(color); - } - SpriteBatchNode::setColor(color); } void Label::updateColor() { - Color4B color4( _displayedColor.r, _displayedColor.g, _displayedColor.b, _displayedOpacity ); - if (_textSprite) - { - _textSprite->setColor(_displayedColor); - _textSprite->setOpacity(_displayedOpacity); - } - if (nullptr == _textureAtlas) { return; } + Color4B color4( _displayedColor.r, _displayedColor.g, _displayedColor.b, _displayedOpacity ); + // special opacity for premultiplied textures if (_isOpacityModifyRGB) { diff --git a/cocos/2d/CCLabel.h b/cocos/2d/CCLabel.h index 2e4ecea274..ef1d8ea07c 100644 --- a/cocos/2d/CCLabel.h +++ b/cocos/2d/CCLabel.h @@ -205,7 +205,7 @@ public: virtual bool isOpacityModifyRGB() const override; virtual void setOpacityModifyRGB(bool isOpacityModifyRGB) override; - virtual void setColor(const Color3B& color) override; + virtual void updateDisplayedColor(const Color3B& parentColor) override; virtual Sprite * getLetter(int lettetIndex);