add disableCascadeOpacity to ProtectedNode and Scale9Sprite

This commit is contained in:
andyque 2014-08-22 11:49:39 +08:00
parent 21cb90bf12
commit 84cf0ee834
5 changed files with 33 additions and 2 deletions

View File

@ -417,4 +417,17 @@ void ProtectedNode::disableCascadeColor()
}
}
void ProtectedNode::disableCascadeOpacity()
{
_displayedOpacity = _realOpacity;
for(auto child : _children){
child->updateDisplayedOpacity(255);
}
for(auto child : _protectedChildren){
child->updateDisplayedOpacity(255);
}
}
NS_CC_END

View File

@ -162,6 +162,7 @@ public:
virtual void updateDisplayedOpacity(GLubyte parentOpacity) override;
virtual void updateDisplayedColor(const Color3B& parentColor) override;
virtual void disableCascadeColor() override;
virtual void disableCascadeOpacity()override;
CC_CONSTRUCTOR_ACCESS:
ProtectedNode();
virtual ~ProtectedNode();

View File

@ -1021,6 +1021,19 @@ y+=ytranslate; \
}
}
void Scale9Sprite::disableCascadeOpacity()
{
_displayedOpacity = _realOpacity;
for(auto child : _children){
child->updateDisplayedOpacity(255);
}
for(auto child : _protectedChildren){
child->updateDisplayedOpacity(255);
}
}
Sprite* Scale9Sprite::getSprite()const
{
return _scale9Image;

View File

@ -305,6 +305,7 @@ namespace ui {
virtual void updateDisplayedOpacity(GLubyte parentOpacity) override;
virtual void updateDisplayedColor(const Color3B& parentColor) override;
virtual void disableCascadeColor() override;
virtual void disableCascadeOpacity() override;
Sprite* getSprite()const;

View File

@ -568,8 +568,11 @@ bool UIS9CascadeOpacityAndColor::init()
rgba->addChild(blocks_scaled_with_insets);
auto actions = Sequence::create(FadeIn::create(1),
TintTo::create(1, 0, 255, 0),
TintTo::create(1, 255, 255, 255),
FadeOut::create(1),
TintTo::create(1, 255, 0, 255),
CallFunc::create([=](){
rgba->setCascadeColorEnabled(false);
rgba->setCascadeOpacityEnabled(false);
}),
nullptr);
auto repeat = RepeatForever::create(actions);
rgba->runAction(repeat);