Skip to content

setOpacity on parent doesn't affect the opacity on children #628

fleet-studio opened this Issue Nov 10, 2012 · 2 comments

3 participants


For example, if you have this scenario:

var child = cc.Sprite.create("res/child_texture.png");
child.setOpacity( 0.5 * 255)
child.setPosition( cc.p( 100, 100 ) );

var parent = cc.Sprite.create("res/parent_texture.png");
parent.setOpacity( 0.5 * 255 );
parent.addChild( child );

You got both the parent and his child with its texture at 50% alpha, is this an expected behaviour?
Shouldn't be parent at 50% alpha and his child at 25% alpha? Isn't opacity relative to ancestors?


If your run this code it looks like a bug:

parent.runAction( cc.FadeOut.create( 1 ) );

You'll see the parent disappearing and the child visible, with his opacity untouched...


No, opacity of child sprite is standalone to his parent.

Only position property is relative to parent sprite in cocos2d.

@linshun linshun closed this Feb 25, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.