Label:Fixed the color of letter will be overridden by fade action.

This commit is contained in:
WenhaiLin 2015-07-15 20:17:05 +08:00
parent bcd20b1bf0
commit 1c9a181c35
3 changed files with 48 additions and 0 deletions

View File

@ -1525,6 +1525,11 @@ void Label::updateDisplayedColor(const Color3B& parentColor)
_shadowNode->updateDisplayedColor(_displayedColor); _shadowNode->updateDisplayedColor(_displayedColor);
} }
} }
for (auto it : _letters)
{
it.second->updateDisplayedColor(_displayedColor);;
}
} }
void Label::updateDisplayedOpacity(GLubyte parentOpacity) void Label::updateDisplayedOpacity(GLubyte parentOpacity)
@ -1539,6 +1544,11 @@ void Label::updateDisplayedOpacity(GLubyte parentOpacity)
_shadowNode->updateDisplayedOpacity(_displayedOpacity); _shadowNode->updateDisplayedOpacity(_displayedOpacity);
} }
} }
for (auto it : _letters)
{
it.second->updateDisplayedOpacity(_displayedOpacity);;
}
} }
void Label::setTextColor(const Color4B &color) void Label::setTextColor(const Color4B &color)

View File

@ -81,6 +81,7 @@ NewLabelTests::NewLabelTests()
ADD_TEST_CASE(LabelIssue12409Test); ADD_TEST_CASE(LabelIssue12409Test);
ADD_TEST_CASE(LabelAddChildTest); ADD_TEST_CASE(LabelAddChildTest);
ADD_TEST_CASE(LabelIssue12775Test); ADD_TEST_CASE(LabelIssue12775Test);
ADD_TEST_CASE(LabelIssue11585Test);
}; };
LabelTTFAlignmentNew::LabelTTFAlignmentNew() LabelTTFAlignmentNew::LabelTTFAlignmentNew()
@ -2017,3 +2018,29 @@ std::string LabelIssue12775Test::subtitle() const
{ {
return "Should not crash if the font not contain a Unicode charmap."; return "Should not crash if the font not contain a Unicode charmap.";
} }
LabelIssue11585Test::LabelIssue11585Test()
{
auto center = VisibleRect::center();
auto label = Label::createWithTTF("Hello World", "fonts/arial.ttf", 24);
label->setPosition(center.x, center.y);
addChild(label);
label->getLetter(0)->setColor(Color3B::RED);
label->getLetter(1)->setColor(Color3B::GREEN);
label->getLetter(2)->setColor(Color3B::BLUE);
auto action = RepeatForever::create(Sequence::create(
FadeOut::create(2), FadeIn::create(2),nullptr));
label->runAction(action);
}
std::string LabelIssue11585Test::title() const
{
return "Test for Issue #11585";
}
std::string LabelIssue11585Test::subtitle() const
{
return "The color of letter should not be overridden by fade action.";
}

View File

@ -619,4 +619,15 @@ public:
virtual std::string subtitle() const override; virtual std::string subtitle() const override;
}; };
class LabelIssue11585Test : public AtlasDemoNew
{
public:
CREATE_FUNC(LabelIssue11585Test);
LabelIssue11585Test();
virtual std::string title() const override;
virtual std::string subtitle() const override;
};
#endif #endif