0

I used CCEffectGlass in Cocos2d 3.2, it works good but I see double layer Or no layer at end like in image. Is it possible to hide double layer only inside circle ?

enter image description here

CODE:

+(void)showGlassEffectForSprite:(CCSprite*)effectBG parent:(CCNode*)inParent
{
    CCSpriteFrame *normalMap = [CCSpriteFrame frameWithImageNamed:@"gtEffectsImage.png"];
    CCSprite *reflectEnvironment = [CCSprite spriteWithImageNamed:@"gtEffectsGlass.jpg"];
    reflectEnvironment.positionType = CCPositionTypeNormalized;
    reflectEnvironment.position = ccp(0.5f, 0.5f);
    reflectEnvironment.visible = NO;

    [inParent addChild:reflectEnvironment];

    CCEffectGlass *glass = [[CCEffectGlass alloc] initWithShininess:1.0f refraction:1.0f refractionEnvironment:effectBG reflectionEnvironment:reflectEnvironment];
    glass.fresnelBias = 0.1f;
    glass.fresnelPower = 2.0f;
    glass.refraction = 0.75f;


    CCSprite *sprite1 = [[CCSprite alloc] init];
    sprite1.position = ccp(SW*0.1f, effectBG.position.y);
    sprite1.normalMapSpriteFrame = normalMap;
    sprite1.effect = glass;
    sprite1.scale = 0.8f;
    sprite1.colorRGBA = [CCColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:0.0f];

    float duration =  4.0f ;

    [sprite1 runAction:[CCActionRepeatForever actionWithAction:[CCActionSequence actions:
                                                                [CCActionMoveTo actionWithDuration:duration position:ccp(SW*1.4f, effectBG.position.y)],
                                                                [CCActionDelay actionWithDuration:1.0f],
                                                                [CCActionMoveTo actionWithDuration:duration position:ccp(-SW*0.4f, effectBG.position.y)],
                                                                [CCActionDelay actionWithDuration:1.0f],
                                                                nil
                                                                ]]];
    [inParent addChild:sprite1 z:5];
}

FULL Xcode Source : https://github.com/Gururajtallur/CCEffectGlassSample

Guru
  • 21,652
  • 10
  • 63
  • 102
  • 2
    not sure what exactly the question is, do you want the behavior at the top of the screenshot but what you see is the bottom half of the screenshot? – CodeSmile Oct 01 '14 at 15:40
  • no, I want top one but its showing double layer. If I hide baseSprite then bottom effect comes..but I want 1st one without double layer. In screenshot tile 'F' is shown twice. – Guru Oct 01 '14 at 15:50

0 Answers0