|
4 | 4 | #import "CCEffectNode.h"
|
5 | 5 | #import "CCEffectBlur.h"
|
6 | 6 |
|
| 7 | +#import "CCEffectStack_Private.h" |
7 | 8 |
|
8 | 9 | @interface CCEffectsTest : TestBase @end
|
9 | 10 | @implementation CCEffectsTest
|
@@ -656,6 +657,156 @@ -(void)setupPerformanceTest
|
656 | 657 | NSLog(@"setupPerformanceTest: Laid out %d sprites.", count);
|
657 | 658 | }
|
658 | 659 |
|
| 660 | +-(void)setupSpriteColorTest |
| 661 | +{ |
| 662 | + self.subTitle = @"Sprite Color + Effects Test\nThe bottom row should look like the top"; |
| 663 | + |
| 664 | + // Make a solid gray background (there's got to be a better way to do this). |
| 665 | + CCEffectNode* background = [[CCEffectNode alloc] init]; |
| 666 | + background.clearFlags = GL_COLOR_BUFFER_BIT; |
| 667 | + background.clearColor = [CCColor grayColor]; |
| 668 | + background.contentSizeType = CCSizeTypeNormalized; |
| 669 | + background.contentSize = CGSizeMake(1.0f, 1.0f); |
| 670 | + background.anchorPoint = ccp(0.5f, 0.5f); |
| 671 | + background.positionType = CCPositionTypeNormalized; |
| 672 | + background.position = ccp(0.5f, 0.5f); |
| 673 | + |
| 674 | + [self.contentNode addChild:background]; |
| 675 | + |
| 676 | + // Add row titles |
| 677 | + CCLabelTTF *plainTitle = [CCLabelTTF labelWithString:@"No FX" fontName:@"HelveticaNeue-Light" fontSize:10 * [CCDirector sharedDirector].UIScaleFactor]; |
| 678 | + plainTitle.color = [CCColor blackColor]; |
| 679 | + plainTitle.positionType = CCPositionTypeNormalized; |
| 680 | + plainTitle.position = ccp(0.1f, 0.7f); |
| 681 | + plainTitle.horizontalAlignment = CCTextAlignmentRight; |
| 682 | + |
| 683 | + [self.contentNode addChild:plainTitle]; |
| 684 | + |
| 685 | + |
| 686 | + CCLabelTTF *effectTitle = [CCLabelTTF labelWithString:@"FX" fontName:@"HelveticaNeue-Light" fontSize:10 * [CCDirector sharedDirector].UIScaleFactor]; |
| 687 | + effectTitle.color = [CCColor blackColor]; |
| 688 | + effectTitle.positionType = CCPositionTypeNormalized; |
| 689 | + effectTitle.position = ccp(0.1f, 0.3f); |
| 690 | + effectTitle.horizontalAlignment = CCTextAlignmentRight; |
| 691 | + |
| 692 | + [self.contentNode addChild:effectTitle]; |
| 693 | + |
| 694 | + |
| 695 | + // Sprite with solid red |
| 696 | + { |
| 697 | + CCEffect *saturation = [CCEffectSaturation effectWithSaturation:0.0f]; |
| 698 | + |
| 699 | + CCSprite *plainSprite = [CCSprite spriteWithImageNamed:@"Images/grossini.png"]; |
| 700 | + plainSprite.positionType = CCPositionTypeNormalized; |
| 701 | + plainSprite.position = ccp(0.2f, 0.7f); |
| 702 | + plainSprite.color = [CCColor redColor]; |
| 703 | + [self.contentNode addChild:plainSprite]; |
| 704 | + |
| 705 | + CCSprite *effectSprite = [CCSprite spriteWithImageNamed:@"Images/grossini.png"]; |
| 706 | + effectSprite.positionType = CCPositionTypeNormalized; |
| 707 | + effectSprite.position = ccp(0.2f, 0.3f); |
| 708 | + effectSprite.color = [CCColor redColor]; |
| 709 | + effectSprite.effect = saturation; |
| 710 | + [self.contentNode addChild:effectSprite]; |
| 711 | + |
| 712 | + CCLabelTTF *title = [CCLabelTTF labelWithString:@"Is color preserved?" fontName:@"HelveticaNeue-Light" fontSize:10 * [CCDirector sharedDirector].UIScaleFactor]; |
| 713 | + title.color = [CCColor blackColor]; |
| 714 | + title.positionType = CCPositionTypeNormalized; |
| 715 | + title.position = ccp(0.2f, 0.05f); |
| 716 | + title.horizontalAlignment = CCTextAlignmentCenter; |
| 717 | + |
| 718 | + [self.contentNode addChild:title]; |
| 719 | + } |
| 720 | + |
| 721 | + |
| 722 | + // Sprite with opacity = 0.5 |
| 723 | + { |
| 724 | + CCEffect *saturation = [CCEffectSaturation effectWithSaturation:0.0f]; |
| 725 | + |
| 726 | + CCSprite *plainSprite = [CCSprite spriteWithImageNamed:@"Images/grossini.png"]; |
| 727 | + plainSprite.positionType = CCPositionTypeNormalized; |
| 728 | + plainSprite.position = ccp(0.4f, 0.7f); |
| 729 | + plainSprite.opacity = 0.5f; |
| 730 | + [self.contentNode addChild:plainSprite]; |
| 731 | + |
| 732 | + CCSprite *effectSprite = [CCSprite spriteWithImageNamed:@"Images/grossini.png"]; |
| 733 | + effectSprite.positionType = CCPositionTypeNormalized; |
| 734 | + effectSprite.position = ccp(0.4f, 0.3f); |
| 735 | + effectSprite.opacity = 0.5f; |
| 736 | + effectSprite.effect = saturation; |
| 737 | + [self.contentNode addChild:effectSprite]; |
| 738 | + |
| 739 | + CCLabelTTF *title = [CCLabelTTF labelWithString:@"Opacity?" fontName:@"HelveticaNeue-Light" fontSize:10 * [CCDirector sharedDirector].UIScaleFactor]; |
| 740 | + title.color = [CCColor blackColor]; |
| 741 | + title.positionType = CCPositionTypeNormalized; |
| 742 | + title.position = ccp(0.4f, 0.05f); |
| 743 | + title.horizontalAlignment = CCTextAlignmentCenter; |
| 744 | + |
| 745 | + [self.contentNode addChild:title]; |
| 746 | + } |
| 747 | + |
| 748 | + |
| 749 | + // Sprite with 50% transparent red |
| 750 | + { |
| 751 | + CCEffect *saturation = [CCEffectSaturation effectWithSaturation:0.0f]; |
| 752 | + CCEffect *hue = [CCEffectHue effectWithHue:0.0f]; |
| 753 | + |
| 754 | + CCEffectStack *stack = [CCEffectStack effectWithArray:@[saturation, hue]]; |
| 755 | + |
| 756 | + CCSprite *plainSprite = [CCSprite spriteWithImageNamed:@"Images/grossini.png"]; |
| 757 | + plainSprite.positionType = CCPositionTypeNormalized; |
| 758 | + plainSprite.position = ccp(0.6f, 0.7f); |
| 759 | + plainSprite.color = [CCColor colorWithRed:0.5f green:0.0f blue:0.0f alpha:0.5f]; |
| 760 | + [self.contentNode addChild:plainSprite]; |
| 761 | + |
| 762 | + CCSprite *effectSprite = [CCSprite spriteWithImageNamed:@"Images/grossini.png"]; |
| 763 | + effectSprite.positionType = CCPositionTypeNormalized; |
| 764 | + effectSprite.position = ccp(0.6f, 0.3f); |
| 765 | + effectSprite.color = [CCColor colorWithRed:0.5f green:0.0f blue:0.0f alpha:0.5f]; |
| 766 | + effectSprite.effect = stack; |
| 767 | + [self.contentNode addChild:effectSprite]; |
| 768 | + |
| 769 | + CCLabelTTF *title = [CCLabelTTF labelWithString:@"Stack (with stitching)" fontName:@"HelveticaNeue-Light" fontSize:10 * [CCDirector sharedDirector].UIScaleFactor]; |
| 770 | + title.color = [CCColor blackColor]; |
| 771 | + title.positionType = CCPositionTypeNormalized; |
| 772 | + title.position = ccp(0.6f, 0.05f); |
| 773 | + title.horizontalAlignment = CCTextAlignmentCenter; |
| 774 | + |
| 775 | + [self.contentNode addChild:title]; |
| 776 | + } |
| 777 | + |
| 778 | + |
| 779 | + // Sprite with 50% transparent red and two stacked effects |
| 780 | + { |
| 781 | + CCEffect *saturation = [CCEffectSaturation effectWithSaturation:0.0f]; |
| 782 | + CCEffect *hue = [CCEffectHue effectWithHue:0.0f]; |
| 783 | + |
| 784 | + CCEffectStack *stack = [CCEffectStack effectWithArray:@[saturation, hue]]; |
| 785 | + stack.stitchingEnabled = NO; |
| 786 | + |
| 787 | + CCSprite *plainSprite = [CCSprite spriteWithImageNamed:@"Images/grossini.png"]; |
| 788 | + plainSprite.positionType = CCPositionTypeNormalized; |
| 789 | + plainSprite.position = ccp(0.8f, 0.7f); |
| 790 | + plainSprite.color = [CCColor colorWithRed:0.5f green:0.0f blue:0.0f alpha:0.5f]; |
| 791 | + [self.contentNode addChild:plainSprite]; |
| 792 | + |
| 793 | + CCSprite *effectSprite = [CCSprite spriteWithImageNamed:@"Images/grossini.png"]; |
| 794 | + effectSprite.positionType = CCPositionTypeNormalized; |
| 795 | + effectSprite.position = ccp(0.8f, 0.3f); |
| 796 | + effectSprite.color = [CCColor colorWithRed:0.5f green:0.0f blue:0.0f alpha:0.5f]; |
| 797 | + effectSprite.effect = stack; |
| 798 | + [self.contentNode addChild:effectSprite]; |
| 799 | + |
| 800 | + CCLabelTTF *title = [CCLabelTTF labelWithString:@"Stack (no stitching)" fontName:@"HelveticaNeue-Light" fontSize:10 * [CCDirector sharedDirector].UIScaleFactor]; |
| 801 | + title.color = [CCColor blackColor]; |
| 802 | + title.positionType = CCPositionTypeNormalized; |
| 803 | + title.position = ccp(0.8f, 0.05f); |
| 804 | + title.horizontalAlignment = CCTextAlignmentCenter; |
| 805 | + |
| 806 | + [self.contentNode addChild:title]; |
| 807 | + } |
| 808 | +} |
| 809 | + |
659 | 810 | -(void)setupEffectNodeAnchorTest
|
660 | 811 | {
|
661 | 812 | self.subTitle = @"Effect Node Anchor Point Test\nTransparent RGB quads from lower-left to upper-right.";
|
|
0 commit comments