diff --git a/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp b/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp index 3b3bc418eb..fbbf47f9ba 100644 --- a/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp +++ b/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp @@ -61,8 +61,6 @@ Scale9Sprite::Scale9Sprite() , _bottom(NULL) , _bottomRight(NULL) , _opacityModifyRGB(false) -, _opacity(255) -, _color(Color3B::WHITE) { } @@ -774,8 +772,7 @@ void Scale9Sprite::visit() void Scale9Sprite::setColor(const Color3B& color) { - _color = color; - + NodeRGBA::setColor(color); Object* child; Array* children = _scale9Image->getChildren(); CCARRAY_FOREACH(children, child) @@ -790,13 +787,12 @@ void Scale9Sprite::setColor(const Color3B& color) const Color3B& Scale9Sprite::getColor() const { - return _color; + return _realColor; } void Scale9Sprite::setOpacity(GLubyte opacity) { - _opacity = opacity; - + NodeRGBA::setOpacity(opacity); Object* child; Array* children = _scale9Image->getChildren(); CCARRAY_FOREACH(children, child) @@ -811,7 +807,37 @@ void Scale9Sprite::setOpacity(GLubyte opacity) GLubyte Scale9Sprite::getOpacity() const { - return _opacity; + return _realOpacity; +} + +void Scale9Sprite::updateDisplayedColor(const cocos2d::Color3B &parentColor) +{ + NodeRGBA::updateDisplayedColor(parentColor); + Object* child; + Array* children = _scale9Image->getChildren(); + CCARRAY_FOREACH(children, child) + { + RGBAProtocol* pNode = dynamic_cast(child); + if (pNode) + { + pNode->updateDisplayedColor(parentColor); + } + } +} + +void Scale9Sprite::updateDisplayedOpacity(GLubyte parentOpacity) +{ + NodeRGBA::updateDisplayedOpacity(parentOpacity); + Object* child; + Array* children = _scale9Image->getChildren(); + CCARRAY_FOREACH(children, child) + { + RGBAProtocol* pNode = dynamic_cast(child); + if (pNode) + { + pNode->updateDisplayedOpacity(parentOpacity); + } + } } NS_CC_EXT_END diff --git a/extensions/GUI/CCControlExtension/CCScale9Sprite.h b/extensions/GUI/CCControlExtension/CCScale9Sprite.h index 88d3026f80..6ecf09d2f6 100644 --- a/extensions/GUI/CCControlExtension/CCScale9Sprite.h +++ b/extensions/GUI/CCControlExtension/CCScale9Sprite.h @@ -97,8 +97,6 @@ protected: Sprite* _bottomRight; bool _opacityModifyRGB; - GLubyte _opacity; - Color3B _color; void updateCapInset(); void updatePositions(); @@ -312,6 +310,9 @@ public: virtual GLubyte getOpacity() const; virtual void setColor(const Color3B& color); virtual const Color3B& getColor() const; + + virtual void updateDisplayedOpacity(GLubyte parentOpacity); + virtual void updateDisplayedColor(const Color3B& parentColor); virtual bool updateWithBatchNode(SpriteBatchNode* batchnode, Rect rect, bool rotated, Rect capInsets);