@@ -135,9 +135,13 @@ -(id)init
135
135
// [self.contentNode addChild:sprite];
136
136
// }
137
137
138
+ // Tests that vertex paging works so that render passes are not limited to 64k vertexes.
139
+ // If vertex paging is broken, rendering will be broken in a very obvious (but undefined) way.
138
140
-(void )setupVertexPagingTest
139
141
{
140
- self.subTitle = @" Should draw a bird." ;
142
+ self.subTitle =
143
+ @" Vertex paging test:\n "
144
+ @" Should draw a bird." ;
141
145
142
146
CCSprite *sprite = [CCSprite spriteWithImageNamed: @" Sprites/bird.png" ];
143
147
sprite.position = ccp (50 , 50 );
@@ -165,9 +169,12 @@ -(void)setupVertexPagingTest
165
169
}
166
170
167
171
#if !__CC_METAL_SUPPORTED_AND_ENABLED
172
+ // Test CCClippingNode.
168
173
-(void )setupClippingNodeTest
169
174
{
170
- self.subTitle = @" ClippingNode test." ;
175
+ self.subTitle =
176
+ @" ClippingNode test.\n "
177
+ @" Should draw a gradient clipped by the shape of a human." ;
171
178
172
179
CGSize size = [CCDirector sharedDirector ].designSize ;
173
180
@@ -198,9 +205,12 @@ -(void)setupClippingNodeTest
198
205
[clip addChild: grad];
199
206
}
200
207
208
+ // Tests [CCRenderTexture newCGImage]
201
209
-(void )setupInfiniteWindowTest
202
210
{
203
- self.subTitle = @" Should draw an infinite window" ;
211
+ self.subTitle =
212
+ @" Should draw an infinite window\n "
213
+ @" Let it run for 10 - 20 seconds to check for memory leaks." ;
204
214
205
215
CCNode *contentNode = self.contentNode ;
206
216
CGSize size = [CCDirector sharedDirector ].designSize ;
@@ -234,6 +244,7 @@ -(void)setupInfiniteWindowTest
234
244
}
235
245
#endif
236
246
247
+ // Tests creating a shader using inline shader code and passing global/per-node uniforms.
237
248
-(CCSprite *)simpleShaderTestHelper
238
249
{
239
250
CCSprite *sprite = [CCSprite spriteWithImageNamed: @" Sprites/bird.png" ];
@@ -283,7 +294,11 @@ void main(void){
283
294
sprite2.position = ccp (0.3 , 0.6 );
284
295
sprite2.shader = shader;
285
296
286
- CCLabelTTF *label1 = [CCLabelTTF labelWithString: @" Using CCDirector.globalShaderUniforms" fontName: @" Helvetica" fontSize: 10.0 ];
297
+ NSString *label1Text =
298
+ @" Using CCDirector.globalShaderUniforms:\n "
299
+ @" Both nodes above should\n "
300
+ @" cycle colors at the same speed." ;
301
+ CCLabelTTF *label1 = [CCLabelTTF labelWithString: label1Text fontName: @" Helvetica" fontSize: 8.0 ];
287
302
label1.positionType = CCPositionTypeNormalized;
288
303
label1.position = ccp (0.3 , 0.3 );
289
304
[self .contentNode addChild: label1];
@@ -292,7 +307,11 @@ void main(void){
292
307
sprite3.position = ccp (0.7 , 0.5 );
293
308
sprite3.shader = shader;
294
309
295
- CCLabelTTF *label2 = [CCLabelTTF labelWithString: @" Using CCNode.shaderUniforms" fontName: @" Helvetica" fontSize: 10.0 ];
310
+ NSString *label2Text =
311
+ @" Using CCNode.shaderUniforms:\n "
312
+ @" The node above should\n "
313
+ @" cycle colors twice as fast as the left nodes." ;
314
+ CCLabelTTF *label2 = [CCLabelTTF labelWithString: label2Text fontName: @" Helvetica" fontSize: 8.0 ];
296
315
label2.positionType = CCPositionTypeNormalized;
297
316
label2.position = ccp (0.7 , 0.3 );
298
317
[self .contentNode addChild: label2];
@@ -338,9 +357,12 @@ -(void)renderTextureHelper:(CCNode *)stage size:(CGSize)size
338
357
[node addChild: sprite];
339
358
}
340
359
360
+ // Tests that render textures work as expected. (flipping, blending, etc)
341
361
-(void )setupRenderTextureTest
342
362
{
343
- self.subTitle = @" Testing CCRenderTexture." ;
363
+ self.subTitle =
364
+ @" Testing CCRenderTexture.\n "
365
+ @" Right side should draw the same as the left, but clipped." ;
344
366
345
367
CGSize size = CGSizeMake (128 , 128 );
346
368
@@ -367,7 +389,8 @@ -(void)setupRenderTextureTest
367
389
renderTexture.autoDraw = YES ;
368
390
}
369
391
370
- -(void )setupShader1Test
392
+ // TODO, this should really be turned into a unit test instead.
393
+ -(void )setupShaderNamedTest_
371
394
{
372
395
self.subTitle = @" Useless fragment shader." ;
373
396
@@ -379,6 +402,8 @@ -(void)setupShader1Test
379
402
[self .contentNode addChild: node];
380
403
}
381
404
405
+ // Tests that CCMotionStreak works like it should.
406
+ // CCMotionStreak assumes non-premultiplied textures so this test will look a little funny.
382
407
- (void )setupMotionStreakNodeTest
383
408
{
384
409
self.subTitle = @" Testing CCMotionStreak" ;
@@ -393,7 +418,7 @@ - (void)setupMotionStreakNodeTest
393
418
394
419
// Maybe want to find a better texture than a random tile graphic?
395
420
{
396
- CCMotionStreak *streak = [CCMotionStreak streakWithFade: 15.0 minSeg: 5 width: 3 color: [CCColor whiteColor ] textureFilename: @" Tiles/05 .png" ];
421
+ CCMotionStreak *streak = [CCMotionStreak streakWithFade: 15.0 minSeg: 5 width: 3 color: [CCColor whiteColor ] textureFilename: @" Images/fire .png" ];
397
422
[stage addChild: streak];
398
423
399
424
[streak scheduleBlock: ^(CCTimer *timer) {
@@ -405,7 +430,7 @@ - (void)setupMotionStreakNodeTest
405
430
[timer repeatOnceWithInterval: 0.01 ];
406
431
} delay: 0.0 ];
407
432
}{
408
- CCMotionStreak *streak = [CCMotionStreak streakWithFade: 0.5 minSeg: 5 width: 3 color: [CCColor redColor ] textureFilename: @" Tiles/05 .png" ];
433
+ CCMotionStreak *streak = [CCMotionStreak streakWithFade: 0.5 minSeg: 5 width: 3 color: [CCColor redColor ] textureFilename: @" Images/fire .png" ];
409
434
[stage addChild: streak];
410
435
411
436
[streak scheduleBlock: ^(CCTimer *timer) {
@@ -668,14 +693,16 @@ - (void)setupProgressNodeTest
668
693
669
694
- (void )setupDrawNodeTest
670
695
{
671
- self.subTitle = @" Testing CCDrawNode" ;
696
+ self.subTitle =
697
+ @" Testing CCDrawNode:\n "
698
+ @" Should draw various shapes." ;
672
699
673
700
CCDrawNode *draw = [CCDrawNode node ];
674
701
675
702
[draw drawDot: ccp (100 , 100 ) radius: 50 color: [CCColor colorWithRed: 0.5 green: 0.0 blue: 0.0 alpha: 0.75 ]];
676
703
677
704
// This yellow dot should not be visible.
678
- [draw drawDot: ccp (150 , 150 ) radius: 50 color: [CCColor colorWithRed: 0.5 green: 0.5 blue: 0.0 alpha: 0.0 ]];
705
+ [draw drawDot: ccp (150 , 150 ) radius: 50 color: [CCColor colorWithRed: 0.5 green: 0.5 blue: 0.0 alpha: 0.5 ]];
679
706
680
707
[draw drawSegmentFrom: ccp (100 , 200 ) to: ccp (200 , 200 ) radius: 25 color: [CCColor colorWithRed: 0.0 green: 0.0 blue: 0.5 alpha: 0.75 ]];
681
708
@@ -691,11 +718,12 @@ - (void)setupDrawNodeTest
691
718
692
719
CGPoint points2[] = {
693
720
{325 , 125 },
694
- {375 , 125 },
695
721
{350 , 200 },
722
+ {375 , 125 },
696
723
};
697
724
[draw drawPolyWithVerts: points2 count: sizeof (points2)/sizeof (*points2) fillColor: [CCColor colorWithRed: 0.0 green: 0.0 blue: 0.0 alpha: 0.75 ] borderWidth: 0.0 borderColor: [CCColor whiteColor ]];
698
725
726
+ [draw runAction: [CCActionFadeIn actionWithDuration: 0.25 ]];
699
727
[self .contentNode addChild: draw];
700
728
}
701
729
0 commit comments