|
4 | 4 | @interface CCRendererTest : TestBase @end
|
5 | 5 | @implementation CCRendererTest
|
6 | 6 |
|
| 7 | +-(void)renderTextureHelper:(CCNode *)stage size:(CGSize)size |
| 8 | +{ |
| 9 | + CCColor *color = [CCColor colorWithRed:0.0 green:0.0 blue:0.5 alpha:0.5]; |
| 10 | + CCNode *node = [CCNodeColor nodeWithColor:color width:128 height:128]; |
| 11 | + [stage addChild:node]; |
| 12 | + |
| 13 | + CCNodeColor *colorNode = [CCNodeColor nodeWithColor:[CCColor greenColor] width:32 height:32]; |
| 14 | + colorNode.anchorPoint = ccp(0.5, 0.5); |
| 15 | + colorNode.position = ccp(size.width, 0); |
| 16 | + [colorNode runAction:[CCActionRepeatForever actionWithAction:[CCActionSequence actions: |
| 17 | + [CCActionMoveTo actionWithDuration:1.0 position:ccp(0, size.height)], |
| 18 | + [CCActionMoveTo actionWithDuration:1.0 position:ccp(size.width, 0)], |
| 19 | + nil |
| 20 | + ]]]; |
| 21 | + [node addChild:colorNode]; |
| 22 | + |
| 23 | + CCSprite *sprite = [CCSprite spriteWithImageNamed:@"Sprites/bird.png"]; |
| 24 | + sprite.opacity = 0.5; |
| 25 | + [sprite runAction:[CCActionRepeatForever actionWithAction:[CCActionSequence actions: |
| 26 | + [CCActionMoveTo actionWithDuration:1.0 position:ccp(size.width, size.height)], |
| 27 | + [CCActionMoveTo actionWithDuration:1.0 position:ccp(0, 0)], |
| 28 | + nil |
| 29 | + ]]]; |
| 30 | + [node addChild:sprite]; |
| 31 | +} |
| 32 | + |
| 33 | +-(void)setupRenderTextureTest |
| 34 | +{ |
| 35 | + self.subTitle = @"Testing CCRenderTexture."; |
| 36 | + |
| 37 | + CGSize size = CGSizeMake(128, 128); |
| 38 | + |
| 39 | + CCNode *stage = [CCNode node]; |
| 40 | + stage.contentSize = size; |
| 41 | + stage.anchorPoint = ccp(0.5, 0.5); |
| 42 | + stage.positionType = CCPositionTypeNormalized; |
| 43 | + stage.position = ccp(0.25, 0.5); |
| 44 | + [self.contentNode addChild:stage]; |
| 45 | + |
| 46 | + [self renderTextureHelper:stage size:size]; |
| 47 | + |
| 48 | + CCRenderTexture *renderTexture = [CCRenderTexture renderTextureWithWidth:size.width height:size.height pixelFormat:CCTexturePixelFormat_RGBA8888]; |
| 49 | + renderTexture.positionType = CCPositionTypeNormalized; |
| 50 | + renderTexture.position = ccp(0.75, 0.5); |
| 51 | + [self.contentNode addChild:renderTexture]; |
| 52 | + |
| 53 | + [self renderTextureHelper:renderTexture size:size]; |
| 54 | + renderTexture.autoDraw = YES; |
| 55 | +} |
| 56 | + |
7 | 57 | - (void)setupMotionStreakNodeTest
|
8 | 58 | {
|
9 | 59 | self.subTitle = @"Testing CCMotionStreak";
|
|
0 commit comments