Skip to content

Commit 3341484

Browse files
committed
More renderer tests.
Former-commit-id: 5a3cf89
1 parent eeab562 commit 3341484

File tree

1 file changed

+97
-0
lines changed

1 file changed

+97
-0
lines changed

cocos2d-ui-tests/tests/CCRendererTest.m

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,53 @@
11
#import "TestBase.h"
2+
#import "CCTextureCache.h"
23

34
@interface CCRendererTest : TestBase @end
45
@implementation CCRendererTest
56

7+
- (void)setupMotionStreakNodeTest
8+
{
9+
self.subTitle = @"Testing CCMotionStreak";
10+
11+
CCNode *stage = [CCNode node];
12+
stage.anchorPoint = ccp(0.5, 0.5);
13+
stage.positionType = CCPositionTypeNormalized;
14+
stage.position = ccp(0.5, 0.5);
15+
stage.contentSizeType = CCSizeTypeNormalized;
16+
stage.contentSize = CGSizeMake(0.75, 0.75);
17+
[self.contentNode addChild:stage];
18+
19+
// Maybe want to find a better texture than a random tile graphic?
20+
{
21+
CCMotionStreak *streak = [CCMotionStreak streakWithFade:15.0 minSeg:5 width:3 color:[CCColor whiteColor] textureFilename:@"Tiles/05.png"];
22+
[stage addChild:streak];
23+
24+
[streak scheduleBlock:^(CCTimer *timer) {
25+
CCTime t = timer.invokeTime;
26+
CGSize size = stage.contentSizeInPoints;
27+
28+
streak.position = ccp(size.width*(0.5 + 0.5*sin(3.1*t)), size.height*(0.5 + 0.5*cos(4.3*t)));
29+
30+
[timer repeatOnceWithInterval:0.01];
31+
} delay:0.0];
32+
}{
33+
CCMotionStreak *streak = [CCMotionStreak streakWithFade:0.5 minSeg:5 width:3 color:[CCColor redColor] textureFilename:@"Tiles/05.png"];
34+
[stage addChild:streak];
35+
36+
[streak scheduleBlock:^(CCTimer *timer) {
37+
CCTime t = timer.invokeTime;
38+
CGSize size = stage.contentSizeInPoints;
39+
40+
streak.position = ccp(size.width*(0.5 + 0.5*sin(1.6*t)), size.height*(0.5 + 0.5*cos(5.1*t)));
41+
42+
[timer repeatOnceWithInterval:0.01];
43+
} delay:0.0];
44+
}
45+
}
46+
647
- (void)setupProgressNodeTest
748
{
49+
self.subTitle = @"Testing various CCProgressNode setups.";
50+
851
// Radial timer
952
{
1053
NSString *image = @"Tiles/05.png";
@@ -158,10 +201,64 @@ - (void)setupProgressNodeTest
158201
[timer repeatOnceWithInterval:interval];
159202
} delay:interval];
160203
}
204+
205+
{
206+
NSString *image = @"Tiles/05.png";
207+
CGPoint position = ccp(0.4, 0.25);
208+
CCTime interval = 1.0/60.0;
209+
210+
CCSprite *sprite = [CCSprite spriteWithImageNamed:image];
211+
sprite.positionType = CCPositionTypeNormalized;
212+
sprite.position = position;
213+
sprite.color = [CCColor grayColor];
214+
[self.contentNode addChild:sprite];
215+
216+
CCProgressNode *progress = [CCProgressNode progressWithSprite:[CCSprite spriteWithImageNamed:image]];
217+
progress.type = CCProgressNodeTypeBar;
218+
progress.midpoint = ccp(0.5, 0.5);
219+
progress.barChangeRate = ccp(1, 1);
220+
progress.positionType = CCPositionTypeNormalized;
221+
progress.position = position;
222+
[self.contentNode addChild:progress];
223+
224+
[self scheduleBlock:^(CCTimer *timer) {
225+
progress.percentage = 100.0*(0.5 + 0.5*sin(timer.invokeTime*M_PI));
226+
227+
[timer repeatOnceWithInterval:interval];
228+
} delay:interval];
229+
}
230+
231+
{
232+
NSString *image = @"Tiles/05.png";
233+
CGPoint position = ccp(0.4, 0.5);
234+
CCTime interval = 1.0/60.0;
235+
236+
CCSprite *sprite = [CCSprite spriteWithImageNamed:image];
237+
sprite.positionType = CCPositionTypeNormalized;
238+
sprite.position = position;
239+
sprite.color = [CCColor grayColor];
240+
[self.contentNode addChild:sprite];
241+
242+
CCProgressNode *progress = [CCProgressNode progressWithSprite:[CCSprite spriteWithImageNamed:image]];
243+
progress.type = CCProgressNodeTypeBar;
244+
progress.midpoint = ccp(0.5, 0.5);
245+
progress.barChangeRate = ccp(0, 0);
246+
progress.positionType = CCPositionTypeNormalized;
247+
progress.position = position;
248+
[self.contentNode addChild:progress];
249+
250+
[self scheduleBlock:^(CCTimer *timer) {
251+
progress.percentage = 100.0*(0.5 + 0.5*sin(timer.invokeTime*M_PI));
252+
253+
[timer repeatOnceWithInterval:interval];
254+
} delay:interval];
255+
}
161256
}
162257

163258
- (void)setupDrawNodeTest
164259
{
260+
self.subTitle = @"Testing CCDrawNode";
261+
165262
CCDrawNode *draw = [CCDrawNode node];
166263

167264
[draw drawDot:ccp(100, 100) radius:50 color:[CCColor redColor]];

0 commit comments

Comments
 (0)