From 5a438ed9a16057845e81bbf31718ede29b92a136 Mon Sep 17 00:00:00 2001 From: WenhaiLin Date: Fri, 17 Apr 2015 15:26:43 +0800 Subject: [PATCH 1/2] Label:Fixed the shadow effect of system font might not be shown. --- cocos/2d/CCLabel.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index 2c039da0c5..659407c250 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -788,17 +788,24 @@ void Label::enableShadow(const Color4B& shadowColor /* = Color4B::BLACK */,const //TODO: support blur for shadow _shadowBlurRadius = 0; - if (_textSprite && _shadowNode) + if (!_systemFontDirty && !_contentDirty && _textSprite) { - if (shadowColor != _shadowColor4F) + if (_shadowNode) { - Node::removeChild(_shadowNode, true); - _shadowNode = nullptr; - createShadowSpriteForSystemFont(); + if (shadowColor != _shadowColor4F) + { + Node::removeChild(_shadowNode, true); + _shadowNode = nullptr; + createShadowSpriteForSystemFont(); + } + else + { + _shadowNode->setPosition(_shadowOffset.width, _shadowOffset.height); + } } else { - _shadowNode->setPosition(_shadowOffset.width, _shadowOffset.height); + createShadowSpriteForSystemFont(); } } From 9c2e39dd49d5122c58653a02f802985e19c25ec8 Mon Sep 17 00:00:00 2001 From: WenhaiLin Date: Fri, 17 Apr 2015 15:42:41 +0800 Subject: [PATCH 2/2] Label:Fixed the shadow color of system font may be incorrect. --- cocos/2d/CCLabel.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index 659407c250..9af6f28f23 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -788,6 +788,11 @@ void Label::enableShadow(const Color4B& shadowColor /* = Color4B::BLACK */,const //TODO: support blur for shadow _shadowBlurRadius = 0; + _shadowColor3B.r = shadowColor.r; + _shadowColor3B.g = shadowColor.g; + _shadowColor3B.b = shadowColor.b; + _shadowOpacity = shadowColor.a; + if (!_systemFontDirty && !_contentDirty && _textSprite) { if (_shadowNode) @@ -809,11 +814,6 @@ void Label::enableShadow(const Color4B& shadowColor /* = Color4B::BLACK */,const } } - _shadowColor3B.r = shadowColor.r; - _shadowColor3B.g = shadowColor.g; - _shadowColor3B.b = shadowColor.b; - _shadowOpacity = shadowColor.a; - _shadowColor4F.r = shadowColor.r / 255.0f; _shadowColor4F.g = shadowColor.g / 255.0f; _shadowColor4F.b = shadowColor.b / 255.0f; @@ -1045,18 +1045,18 @@ void Label::createSpriteForSystemFont() void Label::createShadowSpriteForSystemFont() { - if (!_fontDefinition._stroke._strokeEnabled && _fontDefinition._fontFillColor == _shadowColor4F - && (_fontDefinition._fontAlpha == _shadowColor4F.a * 255)) + if (!_fontDefinition._stroke._strokeEnabled && _fontDefinition._fontFillColor == _shadowColor3B + && (_fontDefinition._fontAlpha == _shadowOpacity)) { _shadowNode = Sprite::createWithTexture(_textSprite->getTexture()); } else { auto shadowFontDefinition = _fontDefinition; - shadowFontDefinition._fontFillColor.r = _shadowColor4F.r * 255; - shadowFontDefinition._fontFillColor.g = _shadowColor4F.g * 255; - shadowFontDefinition._fontFillColor.b = _shadowColor4F.b * 255; - shadowFontDefinition._fontAlpha = _shadowColor4F.a * 255; + shadowFontDefinition._fontFillColor.r = _shadowColor3B.r; + shadowFontDefinition._fontFillColor.g = _shadowColor3B.g; + shadowFontDefinition._fontFillColor.b = _shadowColor3B.b; + shadowFontDefinition._fontAlpha = _shadowOpacity; shadowFontDefinition._stroke._strokeColor = shadowFontDefinition._fontFillColor; shadowFontDefinition._stroke._strokeAlpha = shadowFontDefinition._fontAlpha;