merge setcameramask

This commit is contained in:
yangxiao 2015-02-26 15:33:18 +08:00
commit a1642757f9
6 changed files with 30 additions and 1 deletions

View File

@ -268,6 +268,7 @@ Vec3 Camera::unproject(const Vec3* src) const
CCASSERT(src, "vec3 being projected can not be null");
auto viewport = Director::getInstance()->getWinSize();
Vec4 screen(src->x / viewport.width, ((viewport.height - src->y)) / viewport.height, src->z, 1.0f);
screen.x = screen.x * 2.0f - 1.0f;
screen.y = screen.y * 2.0f - 1.0f;

View File

@ -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();

View File

@ -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

View File

@ -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();

View File

@ -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);
}
}
}}

View File

@ -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();