override updateDisplayedColor and updateDisplayedOpacity method in Scale9Sprite class

This commit is contained in:
pktangyue 2013-07-15 20:10:55 +08:00
parent 6bb2d64f19
commit 652f679d50
2 changed files with 37 additions and 10 deletions

View File

@ -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<RGBAProtocol*>(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<RGBAProtocol*>(child);
if (pNode)
{
pNode->updateDisplayedOpacity(parentOpacity);
}
}
}
NS_CC_EXT_END

View File

@ -97,8 +97,6 @@ protected:
Sprite* _bottomRight;
bool _opacityModifyRGB;
GLubyte _opacity;
Color3B _color;
void updateCapInset();
void updatePositions();
@ -313,6 +311,9 @@ public:
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);
virtual void setSpriteFrame(SpriteFrame * spriteFrame);