Skip to content

Commit ab03552

Browse files
committed
Adding renderer tests for CCClippingNode.
1 parent a9bd61f commit ab03552

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

cocos2d-ui-tests/tests/CCRendererTest.m

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,37 @@
44
@interface CCRendererTest : TestBase @end
55
@implementation CCRendererTest
66

7+
-(void)setupClippingNodeTest
8+
{
9+
CGSize size = [CCDirector sharedDirector].designSize;
10+
11+
CCNode *parent = self.contentNode;
12+
13+
// CCRenderTexture *parent = [CCRenderTexture renderTextureWithWidth:size.width height:size.height pixelFormat:CCTexturePixelFormat_RGBA8888 depthStencilFormat:GL_DEPTH24_STENCIL8_OES];
14+
// parent.positionType = CCPositionTypeNormalized;
15+
// parent.position = ccp(0.5, 0.5);
16+
// parent.autoDraw = YES;
17+
// parent.clearColor = [CCColor blackColor];
18+
// parent.clearDepth = 1.0;
19+
// parent.clearStencil = 0;
20+
// parent.clearFlags = GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT;
21+
// [self.contentNode addChild:parent];
22+
23+
CCNodeGradient *grad = [CCNodeGradient nodeWithColor:[CCColor redColor] fadingTo:[CCColor blueColor] alongVector:ccp(1, 1)];
24+
// [parent addChild:grad];
25+
26+
CCNode *stencil = [CCSprite spriteWithImageNamed:@"Sprites/grossini.png"];
27+
// [parent addChild:stencil];
28+
stencil.position = ccp(size.width/2, size.height/2);
29+
stencil.scale = 3.0;
30+
[stencil runAction:[CCActionRepeatForever actionWithAction:[CCActionRotateBy actionWithDuration:1.0 angle:90.0]]];
31+
32+
CCClippingNode *clip = [CCClippingNode clippingNodeWithStencil:stencil];
33+
[parent addChild:clip];
34+
clip.alphaThreshold = 0.5;
35+
[clip addChild:grad];
36+
}
37+
738
-(void)renderTextureHelper:(CCNode *)stage size:(CGSize)size
839
{
940
CCColor *color = [CCColor colorWithRed:0.0 green:0.0 blue:0.5 alpha:0.5];

0 commit comments

Comments
 (0)