Merge pull request #5860 from Dhilan007/develop_label

closed #4434: Label's color is incorrect if it's created by font name
This commit is contained in:
James Chen 2014-03-19 14:09:32 +08:00
commit 7061641dd8
2 changed files with 21 additions and 16 deletions

View File

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

View File

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