The opacity property does not get propagated to the children. If you want , you can override the setOpacity method :
// in your .h file, an iVar
GLubyte _opacity;
// in you .m, the overrides
- (void)setOpacity:(GLubyte)opacity {
for (id child in self.children) {
id <CCRGBAProtocol> opaqueChild = (id <CCRGBAProtocol>) child;
if ([opaqueChild respondsToSelector:@selector(setOpacity:)]) {
opaqueChild.opacity = opacity;
} else {
// you must decide here what to do for your own situation
// and the children you are likely to have in there
}
}
_opacity = opacity;
}
- (GLubyte)opacity {
return _opacity;
}
edit : extending a CCLayerColor (this compiles, have not actually tested it, but should work). Just add this in your .m file (the implementation for your class) :
- (void)setOpacity:(GLubyte)opacity {
for (id child in self.children) {
id <CCRGBAProtocol> opaqueChild = (id <CCRGBAProtocol>) child;
if ([opaqueChild respondsToSelector:@selector(setOpacity:)]) {
opaqueChild.opacity = opacity;
} else {
// you must decide here what to do for your own situation
// and the children you are likely to have in there
}
}
[super setOpacity:opacity];
}