From ee03bb8eeaba0ebaf63fed7c8d926d9ff4f30c5f Mon Sep 17 00:00:00 2001 From: lvlong Date: Thu, 12 Feb 2015 09:24:04 +0800 Subject: [PATCH] setCameraMask for cocostudio-ui --- cocos/2d/CCNode.h | 2 +- cocos/2d/CCProtectedNode.cpp | 13 +++++++++++++ cocos/2d/CCProtectedNode.h | 1 + cocos/ui/UIScale9Sprite.cpp | 13 +++++++++++++ cocos/ui/UIScale9Sprite.h | 1 + 5 files changed, 29 insertions(+), 1 deletion(-) diff --git a/cocos/2d/CCNode.h b/cocos/2d/CCNode.h index 89f8d8da82..2f1cc05e49 100644 --- a/cocos/2d/CCNode.h +++ b/cocos/2d/CCNode.h @@ -1575,7 +1575,7 @@ public: /** get & set camera mask, the node is visible by the camera whose camera flag & node's camera mask is true */ unsigned short getCameraMask() const { return _cameraMask; } - void setCameraMask(unsigned short mask, bool applyChildren = true); + virtual void setCameraMask(unsigned short mask, bool applyChildren = true); CC_CONSTRUCTOR_ACCESS: // Nodes should be created using create(); diff --git a/cocos/2d/CCProtectedNode.cpp b/cocos/2d/CCProtectedNode.cpp index b5f078a394..3acb2cd79a 100644 --- a/cocos/2d/CCProtectedNode.cpp +++ b/cocos/2d/CCProtectedNode.cpp @@ -431,4 +431,17 @@ void ProtectedNode::disableCascadeOpacity() } } +void ProtectedNode::setCameraMask(unsigned short mask, bool applyChildren) +{ + Node::setCameraMask(mask, applyChildren); + if (applyChildren) + { + for (auto& iter: _protectedChildren) + { + iter->setCameraMask(mask); + } + } + +} + NS_CC_END diff --git a/cocos/2d/CCProtectedNode.h b/cocos/2d/CCProtectedNode.h index dff7fae398..6d9bc816de 100644 --- a/cocos/2d/CCProtectedNode.h +++ b/cocos/2d/CCProtectedNode.h @@ -163,6 +163,7 @@ public: virtual void updateDisplayedColor(const Color3B& parentColor) override; virtual void disableCascadeColor() override; virtual void disableCascadeOpacity()override; + virtual void setCameraMask(unsigned short mask, bool applyChildren = true) override; CC_CONSTRUCTOR_ACCESS: ProtectedNode(); virtual ~ProtectedNode(); diff --git a/cocos/ui/UIScale9Sprite.cpp b/cocos/ui/UIScale9Sprite.cpp index 2eb24bca17..32562578aa 100644 --- a/cocos/ui/UIScale9Sprite.cpp +++ b/cocos/ui/UIScale9Sprite.cpp @@ -1335,4 +1335,17 @@ namespace ui { return this->getScaleX(); } + void Scale9Sprite::setCameraMask(unsigned short mask, bool applyChildren) + { + Node::setCameraMask(mask, applyChildren); + + if(_scale9Image) + _scale9Image->setCameraMask(mask,applyChildren); + + for(auto& iter: _protectedChildren) + { + iter->setCameraMask(mask); + } + } + }} diff --git a/cocos/ui/UIScale9Sprite.h b/cocos/ui/UIScale9Sprite.h index c0f0bc2bdf..2fd95c0e93 100644 --- a/cocos/ui/UIScale9Sprite.h +++ b/cocos/ui/UIScale9Sprite.h @@ -376,6 +376,7 @@ namespace ui { virtual float getScaleY() const override; virtual float getScale() const override; using Node::getScaleZ; + virtual void setCameraMask(unsigned short mask, bool applyChildren = true) override; protected: void updateCapInset(); void updatePositions();