Skip to content

Commit b343c8b

Browse files
author
Thayer J Andrews
committed
CCEffectsTest - Add the latest effects to the performance test
1 parent 7fc4ffd commit b343c8b

File tree

1 file changed

+64
-11
lines changed

1 file changed

+64
-11
lines changed

cocos2d-ui-tests/tests/CCEffectsTest.m

Lines changed: 64 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -495,20 +495,58 @@ -(void)setupHueEffectTest
495495
-(void)setupPerformanceTest
496496
{
497497
self.subTitle = @"Effect Performance Test";
498+
499+
CCSprite *reflectEnvironment = [CCSprite spriteWithImageNamed:@"Images/MountainPanorama.jpg"];
500+
reflectEnvironment.positionType = CCPositionTypeNormalized;
501+
reflectEnvironment.position = ccp(0.5f, 0.5f);
502+
reflectEnvironment.visible = NO;
503+
504+
CCSprite *refractEnvironment = [CCSprite spriteWithImageNamed:@"Images/StoneWall.jpg"];
505+
refractEnvironment.positionType = CCPositionTypeNormalized;
506+
refractEnvironment.position = ccp(0.5f, 0.5f);
507+
refractEnvironment.scale = 0.5;
508+
509+
NSArray *allEffects = @[
510+
[CCEffectGaussianBlur effectWithPixelBlurRadius:7.0],
511+
[CCEffectBloom effectWithPixelBlurRadius:8 intensity:1.0f luminanceThreshold:0.0f],
512+
[CCEffectBrightness effectWithBrightness:0.25f],
513+
[CCEffectContrast effectWithContrast:1.0f],
514+
[CCEffectPixellate effectWithBlockSize:4.0f],
515+
[CCEffectSaturation effectWithSaturation:-1.0f],
516+
[CCEffectHue effectWithHue:90.0f],
517+
[CCEffectGlass effectWithRefraction:0.5f refractionEnvironment:refractEnvironment reflectionEnvironment:reflectEnvironment normalMap:nil],
518+
[CCEffectRefraction effectWithRefraction:0.5f environment:refractEnvironment normalMap:nil],
519+
[CCEffectReflection effectWithEnvironment:reflectEnvironment normalMap:nil],
520+
];
521+
CCEffect *selectedEffect = allEffects[8];
522+
523+
524+
CCSpriteFrame *normalMap = nil;
525+
if ([selectedEffect.debugName isEqualToString:@"CCEffectGlass"])
526+
{
527+
[self.contentNode addChild:reflectEnvironment];
528+
[self.contentNode addChild:refractEnvironment];
529+
normalMap = [CCSpriteFrame frameWithImageNamed:@"Images/ShinyBallNormals.png"];
530+
}
531+
else if ([selectedEffect.debugName isEqualToString:@"CCEffectRefraction"])
532+
{
533+
[self.contentNode addChild:refractEnvironment];
534+
normalMap = [CCSpriteFrame frameWithImageNamed:@"Images/ShinyBallNormals.png"];
535+
}
536+
else if ([selectedEffect.debugName isEqualToString:@"CCEffectReflection"])
537+
{
538+
[self.contentNode addChild:reflectEnvironment];
539+
normalMap = [CCSpriteFrame frameWithImageNamed:@"Images/ShinyBallNormals.png"];
540+
}
498541

499-
// CCEffect *glow = [CCEffectGlow effectWithBlurStrength:0.02f];
500-
// CCEffect *brightness = [[CCEffectBrightness alloc] initWithBrightness:0.25f];
501-
// CCEffect *contrast = [[CCEffectContrast alloc] initWithContrast:1.0f];
502-
// CCEffect *pixellate = [[CCEffectPixellate alloc] initWithBlockSize:4.0f];
503-
// CCEffect *blur = [CCEffectGaussianBlur effectWithBlurStrength:0.02f direction:GLKVector2Make(1.0, 1.0)];
504-
CCEffect *saturation = [[CCEffectSaturation alloc] initWithSaturation:0.0f];
505-
NSArray *effects = @[saturation];
506542

507543
CGSize containerSize = self.contentNode.contentSizeInPoints;
508544

509-
NSString *spriteImage = @"Images/snow.png";
510545
const float footprintScale = 1.1f;
511-
CCSprite *sprite = [self spriteWithEffects:effects image:spriteImage atPosition:ccp(0, 0)];
546+
547+
NSString *spriteImage = @"Images/r1.png";
548+
CCSprite *sprite = [CCSprite spriteWithImageNamed:spriteImage];
549+
512550
CGSize spriteSize = sprite.contentSizeInPoints;
513551
CGSize spriteFootprint = CGSizeMake(spriteSize.width * footprintScale, spriteSize.height * footprintScale);
514552
CGSize allSpritesBounds = CGSizeMake(((int)(containerSize.width / spriteFootprint.width) * spriteFootprint.width),
@@ -521,10 +559,25 @@ -(void)setupPerformanceTest
521559
{
522560
for (float xPos = origin.x; (xPos + spriteFootprint.width) < containerSize.width; xPos += spriteFootprint.width)
523561
{
524-
sprite = [self spriteWithEffects:effects image:spriteImage atPosition:ccp(xPos, yPos)];
525-
sprite.anchorPoint = ccp(0.0f, 0.0f);
562+
if (normalMap)
563+
{
564+
sprite = [[CCSprite alloc] init];
565+
sprite.normalMapSpriteFrame = normalMap;
566+
sprite.scale = 0.1f;
567+
sprite.colorRGBA = [CCColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:0.0f];
568+
}
569+
else
570+
{
571+
sprite = [CCSprite spriteWithImageNamed:spriteImage];
572+
}
573+
526574
sprite.positionType = CCPositionTypePoints;
575+
sprite.position = ccp(xPos, yPos);
576+
sprite.anchorPoint = ccp(0.0f, 0.0f);
577+
sprite.effect = selectedEffect;
578+
527579
[self.contentNode addChild:sprite];
580+
528581
count++;
529582
}
530583
}

0 commit comments

Comments
 (0)