@@ -856,6 +856,41 @@ -(void)setupSpriteColorTest
856
856
}
857
857
}
858
858
859
+ -(void )setupClipWithEffectsTest
860
+ {
861
+ self.subTitle = @" Clipping + Effects Test." ;
862
+
863
+ CGSize size = [CCDirector sharedDirector ].designSize ;
864
+
865
+ CCNodeGradient *grad = [CCNodeGradient nodeWithColor: [CCColor redColor ] fadingTo: [CCColor blueColor ] alongVector: ccp (1 , 0 )];
866
+
867
+ CCNode *stencil = [CCSprite spriteWithImageNamed: @" Sprites/grossini.png" ];
868
+ stencil.position = ccp (size.width /2 , size.height /2 );
869
+ stencil.scale = 4.0 ;
870
+ [stencil runAction: [CCActionRepeatForever actionWithAction: [CCActionRotateBy actionWithDuration: 1.0 angle: 90.0 ]]];
871
+
872
+ CCClippingNode *clip = [CCClippingNode clippingNodeWithStencil: stencil];
873
+ clip.alphaThreshold = 0.5 ;
874
+
875
+ CCEffectNode* parent = [CCEffectNode effectNodeWithWidth: size.width height: size.height pixelFormat: CCTexturePixelFormat_RGBA8888 depthStencilFormat: GL_DEPTH24_STENCIL8];
876
+ parent.clearFlags = GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT;
877
+ parent.clearColor = [CCColor blackColor ];
878
+ parent.clearDepth = 1.0 ;
879
+ parent.clearStencil = 0 ;
880
+ parent.contentSizeType = CCSizeTypeNormalized;
881
+ parent.contentSize = CGSizeMake (1 .0f , 1 .0f );
882
+ parent.anchorPoint = ccp (0 .5f , 0 .5f );
883
+ parent.positionType = CCPositionTypeNormalized;
884
+ parent.position = ccp (0 .5f , 0 .5f );
885
+
886
+ CCEffectPixellate *effect = [CCEffectStack effectWithArray: @[[CCEffectPixellate effectWithBlockSize: 4 .0f ], [CCEffectSaturation effectWithSaturation: 1 .0f ]]];
887
+ parent.effect = effect;
888
+
889
+ [clip addChild: grad];
890
+ [parent addChild: clip];
891
+ [self .contentNode addChild: parent];
892
+ }
893
+
859
894
-(void )setupEffectNodeAnchorTest
860
895
{
861
896
self.subTitle = @" Effect Node Anchor Point Test\n Transparent RGB quads from lower-left to upper-right." ;
0 commit comments