diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index 287011a9c7..f27786f537 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -1525,6 +1525,11 @@ void Label::updateDisplayedColor(const Color3B& parentColor) _shadowNode->updateDisplayedColor(_displayedColor); } } + + for (auto it : _letters) + { + it.second->updateDisplayedColor(_displayedColor);; + } } void Label::updateDisplayedOpacity(GLubyte parentOpacity) @@ -1539,6 +1544,11 @@ void Label::updateDisplayedOpacity(GLubyte parentOpacity) _shadowNode->updateDisplayedOpacity(_displayedOpacity); } } + + for (auto it : _letters) + { + it.second->updateDisplayedOpacity(_displayedOpacity);; + } } void Label::setTextColor(const Color4B &color) diff --git a/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp b/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp index 0b79bd2f12..4dd465b206 100644 --- a/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp +++ b/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp @@ -81,6 +81,7 @@ NewLabelTests::NewLabelTests() ADD_TEST_CASE(LabelIssue12409Test); ADD_TEST_CASE(LabelAddChildTest); ADD_TEST_CASE(LabelIssue12775Test); + ADD_TEST_CASE(LabelIssue11585Test); }; LabelTTFAlignmentNew::LabelTTFAlignmentNew() @@ -2017,3 +2018,29 @@ std::string LabelIssue12775Test::subtitle() const { 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."; +} diff --git a/tests/cpp-tests/Classes/LabelTest/LabelTestNew.h b/tests/cpp-tests/Classes/LabelTest/LabelTestNew.h index 6b170d28ff..52a9b5a9bf 100644 --- a/tests/cpp-tests/Classes/LabelTest/LabelTestNew.h +++ b/tests/cpp-tests/Classes/LabelTest/LabelTestNew.h @@ -619,4 +619,15 @@ public: 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