Blur CCLayerColor (to pause)

I'm curious if anyone knows about an already implemented way to blur all CCLayer. I use a simple CCLayerColor set to black with a little opacity, but I would like to be able to blur the background enough to make the drops indistinguishable.

+5
source share
2 answers

You can do this with CCLayerColor.

-(void)fadeBackground
{
    ccColor4B color = {0,0,0,255};
    CCLayerColor *fadeLayer = [CCLayerColor layerWithColor:color];
    [self addChild:fadeLayer z:7];
    fadeLayer.opacity = 0;

    id fade   = [CCFadeTo actionWithDuration:1.0f opacity:160];//200 for light blur
    id calBlk = [CCCallBlock actionWithBlock:^{
        //show pause screen buttons here 
        //[self showPauseMenu];
    }];
    id sequen = [CCSequence actions:fade, calBlk, nil];

    [fadeLayer runAction:sequen];
}
0
source

Could you just create a small tile that will be translucent with some noise in it and create a sprite that covers the screen, where the texture settings are set to repeat?

CCSprite *blurSprite = [CCSprite spriteWithFile:@"blurtile.png" rect:CGRectMake(0, 0, 1024, 768)];
blurSprite.position = ccp(512,384);
ccTexParams params = {GL_LINEAR,GL_LINEAR,GL_REPEAT,GL_REPEAT};
[blurSprite .texture setTexParameters:&params];
[self addChild:blurSprite];

These parameters may be a little erroneous, but this should give a general idea.

0
source

All Articles