From 6f50143e0a87e5d1a33e51afd3411e65629a2946 Mon Sep 17 00:00:00 2001 From: Dhilan007 Date: Wed, 8 Oct 2014 18:28:24 +0800 Subject: [PATCH] Fixed LabelAtlas opacity do not change when setting parent node's opacity --- cocos/2d/CCAtlasNode.cpp | 8 ++++++++ cocos/2d/CCLabelAtlas.cpp | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/cocos/2d/CCAtlasNode.cpp b/cocos/2d/CCAtlasNode.cpp index e885655384..77d2aadb8a 100644 --- a/cocos/2d/CCAtlasNode.cpp +++ b/cocos/2d/CCAtlasNode.cpp @@ -216,7 +216,15 @@ void AtlasNode::setBlendFunc(const BlendFunc &blendFunc) void AtlasNode::updateBlendFunc() { if( ! _textureAtlas->getTexture()->hasPremultipliedAlpha() ) + { _blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED; + setOpacityModifyRGB(false); + } + else + { + _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; + setOpacityModifyRGB(true); + } } void AtlasNode::setTexture(Texture2D *texture) diff --git a/cocos/2d/CCLabelAtlas.cpp b/cocos/2d/CCLabelAtlas.cpp index aa0750e906..2134af1925 100644 --- a/cocos/2d/CCLabelAtlas.cpp +++ b/cocos/2d/CCLabelAtlas.cpp @@ -233,6 +233,12 @@ void LabelAtlas::updateColor() if (_textureAtlas) { Color4B color4( _displayedColor.r, _displayedColor.g, _displayedColor.b, _displayedOpacity ); + if (_isOpacityModifyRGB) + { + color4.r *= _displayedOpacity/255.0f; + color4.g *= _displayedOpacity/255.0f; + color4.b *= _displayedOpacity/255.0f; + } auto quads = _textureAtlas->getQuads(); ssize_t length = _string.length(); for (int index = 0; index < length; index++)