diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CCBoneNode.cpp b/cocos/editor-support/cocostudio/ActionTimeline/CCBoneNode.cpp index 1cb40ca31d..e3fa31a5cc 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CCBoneNode.cpp +++ b/cocos/editor-support/cocostudio/ActionTimeline/CCBoneNode.cpp @@ -74,14 +74,14 @@ BoneNode* BoneNode::create(int length) void BoneNode::addChild(cocos2d::Node* child, int localZOrder, int tag) { - Node::addChild(child, localZOrder, tag); addToChildrenListHelper(child); + Node::addChild(child, localZOrder, tag); } void BoneNode::addChild(Node* child, int localZOrder, const std::string &name) { - Node::addChild(child, localZOrder, name); addToChildrenListHelper(child); + Node::addChild(child, localZOrder, name); } void BoneNode::addSkin(SkinNode* skin, bool isDisplay, bool hideOthers) @@ -441,6 +441,44 @@ void BoneNode::updateColor() _transformUpdated = _transformDirty = _inverseDirty = _contentSizeDirty = true; } +void BoneNode::updateDisplayedColor(const cocos2d::Color3B& parentColor) +{ + if (_cascadeColorEnabled) + { + for (const auto &child : _boneSkins) + { + child->updateDisplayedColor(_displayedColor); + } + } +} + +void BoneNode::updateDisplayedOpacity(GLubyte parentOpacity) +{ + if (_cascadeOpacityEnabled) + { + for (const auto& child : _boneSkins) + { + child->updateDisplayedOpacity(_displayedOpacity); + } + } +} + +void BoneNode::disableCascadeOpacity() +{ + for (const auto& child : _boneSkins) + { + child->updateDisplayedOpacity(255); + } +} + +void BoneNode::disableCascadeColor() +{ + for (const auto& child : _boneSkins) + { + child->updateDisplayedColor(cocos2d::Color3B::WHITE); + } +} + void BoneNode::onDraw(const cocos2d::Mat4 &transform, uint32_t flags) { getGLProgram()->use(); diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CCBoneNode.h b/cocos/editor-support/cocostudio/ActionTimeline/CCBoneNode.h index 8fe804dd62..0190348149 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CCBoneNode.h +++ b/cocos/editor-support/cocostudio/ActionTimeline/CCBoneNode.h @@ -185,6 +185,12 @@ protected: virtual void updateVertices(); virtual void updateColor() override; + // bone's color and opacity cannot cascade to bone + virtual void updateDisplayedColor(const cocos2d::Color3B& parentColor) override; + virtual void updateDisplayedOpacity(GLubyte parentOpacity) override; + virtual void disableCascadeOpacity() override; + virtual void disableCascadeColor() override; + virtual void onDraw(const cocos2d::Mat4 &transform, uint32_t flags); // override Node::visit, just visit bones in children