mirror of https://github.com/axmolengine/axmol.git
closed issue#4434:fixed display incorrect color of label if create by font name.
This commit is contained in:
parent
a286ed8374
commit
f76460aee8
|
@ -457,6 +457,17 @@ void Label::setFontDefinition(const FontDefinition& textDefinition)
|
||||||
{
|
{
|
||||||
reset();
|
reset();
|
||||||
_fontDefinition = textDefinition;
|
_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;
|
_fontName = textDefinition._fontName;
|
||||||
_fontSize = textDefinition._fontSize;
|
_fontSize = textDefinition._fontSize;
|
||||||
_contentDirty = true;
|
_contentDirty = true;
|
||||||
|
@ -1150,34 +1161,28 @@ void Label::setOpacityModifyRGB(bool isOpacityModifyRGB)
|
||||||
_reusedLetter->setOpacityModifyRGB(true);
|
_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)
|
if (_textSprite)
|
||||||
{
|
{
|
||||||
updateContent();
|
_textSprite->updateDisplayedColor(_displayedColor);
|
||||||
}
|
}
|
||||||
if (_reusedLetter)
|
|
||||||
{
|
|
||||||
_reusedLetter->setColor(color);
|
|
||||||
}
|
|
||||||
SpriteBatchNode::setColor(color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Label::updateColor()
|
void Label::updateColor()
|
||||||
{
|
{
|
||||||
Color4B color4( _displayedColor.r, _displayedColor.g, _displayedColor.b, _displayedOpacity );
|
|
||||||
if (_textSprite)
|
|
||||||
{
|
|
||||||
_textSprite->setColor(_displayedColor);
|
|
||||||
_textSprite->setOpacity(_displayedOpacity);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nullptr == _textureAtlas)
|
if (nullptr == _textureAtlas)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Color4B color4( _displayedColor.r, _displayedColor.g, _displayedColor.b, _displayedOpacity );
|
||||||
|
|
||||||
// special opacity for premultiplied textures
|
// special opacity for premultiplied textures
|
||||||
if (_isOpacityModifyRGB)
|
if (_isOpacityModifyRGB)
|
||||||
{
|
{
|
||||||
|
|
|
@ -205,7 +205,7 @@ public:
|
||||||
|
|
||||||
virtual bool isOpacityModifyRGB() const override;
|
virtual bool isOpacityModifyRGB() const override;
|
||||||
virtual void setOpacityModifyRGB(bool isOpacityModifyRGB) override;
|
virtual void setOpacityModifyRGB(bool isOpacityModifyRGB) override;
|
||||||
virtual void setColor(const Color3B& color) override;
|
virtual void updateDisplayedColor(const Color3B& parentColor);
|
||||||
|
|
||||||
virtual Sprite * getLetter(int lettetIndex);
|
virtual Sprite * getLetter(int lettetIndex);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue