For a Lightbox kind of effect in cocos2d you can have two layers
1) Background Layer
2) Pop up Layer
When Pop up Layer is shown we need to make the background layer darker.
First thing to be able to make the background layer darker is to extend the background layer from CCColorLayer.
But now if you try to call setOpacity on the layer only the layer will become darker, all the sprites on the layer will still be regular.
To make all sprites of the layer also darker you can override the setOpacity method in your Layer class as shown below