Skip to content

Commit 337fa5a

Browse files
committed
Adding a simple CCRenderTexture test
Former-commit-id: 05d70e9
1 parent 4deca65 commit 337fa5a

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

cocos2d-ui-tests/tests/CCRendererTest.m

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

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+
757
- (void)setupMotionStreakNodeTest
858
{
959
self.subTitle = @"Testing CCMotionStreak";

0 commit comments

Comments
 (0)