cocos2d / cocos2d-html5

Cocos2d for Web Browsers. Built using JavaScript.
https://www.cocos.com
3.07k stars 902 forks source link

Father Sprite setOpacity can not Superimposed to Son Sprite? #1476

Closed breathxue closed 10 years ago

breathxue commented 10 years ago

Father Node setOpacity can not Superimposed to Child Node?

SpriteA.addChild(SpriteB) SpriteA.setOpacity(127);

But SpriteB does not seem transparent


father node setCascadeOpacityEnabled can not Superimposed to grandson node

SpriteA.addChild(SpriteB)
SpriteB.addChild(SpriteC)
//SpriteB.setCascadeOpacityEnabled(true) // SpriteB also setCascadeOpacityEnabled, it`s hard to used
SpriteA.setCascadeOpacityEnabled(true)
SpriteA.setOpacity(127);

If new Child add in Father Node, you must reset Opacity, But same problem did not appear in LayerColor.

SpriteA.setCascadeOpacityEnabled(true)
SpriteA.addChild(SpriteB)
SpriteA.setOpacity(127);
//run right
SpriteA.addChild(SpriteC)
//SpriteC not transparency
SpriteA.setOpacity(127);
//must setOpacity again
xingsenma commented 10 years ago

Hi,breathxue. You must enabled the cascade opacity,like:

SpriteA.setCascadeOpacityEnabled(true);

breathxue commented 10 years ago

Hi, xingsenma thank you for you help. I test it, but I found new issue

  1. father node setCascadeOpacityEnabled can not Superimposed to grandson node
SpriteA.addChild(SpriteB)
SpriteB.addChild(SpriteC)
//SpriteB.setCascadeOpacityEnabled(true) // SpriteB also setCascadeOpacityEnabled, it`s hard to used
SpriteA.setCascadeOpacityEnabled(true)
SpriteA.setOpacity(127);
  1. If new Child add in Father Node, you must reset Opacity, But same problem did not appear in LayerColor.
SpriteA.setCascadeOpacityEnabled(true)
SpriteA.addChild(SpriteB)
SpriteA.setOpacity(127);
//run right
SpriteA.addChild(SpriteC)
//SpriteC not transparency
SpriteA.setOpacity(127);
//must setOpacity again
dingpinglv commented 10 years ago

Hi,

This bug has been fixed at: https://github.com/cocos2d/cocos2d-html5/pull/1478/files

Thanks for feedback.

breathxue commented 10 years ago

thank you very mush