|
4 | 4 | @interface CCRendererTest : TestBase @end
|
5 | 5 | @implementation CCRendererTest
|
6 | 6 |
|
| 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 | + |
7 | 38 | -(void)renderTextureHelper:(CCNode *)stage size:(CGSize)size
|
8 | 39 | {
|
9 | 40 | CCColor *color = [CCColor colorWithRed:0.0 green:0.0 blue:0.5 alpha:0.5];
|
|
0 commit comments