Merge pull request #8573 from Dhilan007/v3-labelatlas

fix #8569: LabelAtlas opacity do not change when setting parent node's opacity
This commit is contained in:
minggo 2014-10-10 15:52:50 +08:00
commit 4b7d5694b8
2 changed files with 14 additions and 0 deletions

View File

@ -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)

View File

@ -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++)