Change Color of Everything on Screen - Cocos2d
I have a pause button/method(not the greatest but it works). Currently, I am changing the opacity of EVERYTHING on screen when it is paused which is not what I want to do but it works(and is a pain). Does anyone have a better way of changing the brightness of everything on screen at the same time?
E.G. when you pause "Angry Birds"(only game I could think of at the moment) the main scene has a transparent black overlay on it.
Here is my Code
-(void) Pause:(ccTime)delta
{
Bag.opacity = 150;
ScoreH.opacity = 150;
TimerH.opacity = 150;
leftB.opacity开发者_如何学编程 = 150;
rightB.opacity = 150;
bg.opacity = 150;
scoreLabel.opacity = 150;
timeLabel.opacity = 150;
[[CCDirector sharedDirector] pause];
CCLOG(@"Game Paused");
}
Also, most of my sprites come from sprite sheets. I don't know if that helps. Any help is greatly appreciated. Thanks in advance!
Wow... I have been looking for an answer for this for about a month and RIGHT after I ask this question I decide to search it again and... I find it.
Please excuse my stupidity...
CCLayerColor* colorLayer = [CCLayerColor layerWithColor:ccc4(0, 0, 0, 100)];
[self addChild:colorLayer z:0];
The first three numbers are "RBG" colors and the last number is opacity.
To put a color overlay on top of a layer just add..
CCLayerColor* colorLayer = [CCLayerColor layerWithColor:ccc4(0, 0, 0, 128)];
[self addChild:colorLayer z:0];
The first three numbers are "RGB" colors and the last number is opacity. Each can have a value in range between 0 and 255.
E.G.
layerWithColor:ccc4(Red, Green, Blue, Opacity)
精彩评论