4
4
#import " CCEffectNode.h"
5
5
#import " CCEffectBlur.h"
6
6
7
+ #import " CCEffect_Private.h"
7
8
#import " CCEffectStack_Private.h"
8
9
9
10
@interface CCEffectsTest : TestBase @end
@@ -677,7 +678,7 @@ -(void)setupSpriteColorTest
677
678
CCLabelTTF *plainTitle = [CCLabelTTF labelWithString: @" No FX" fontName: @" HelveticaNeue-Light" fontSize: 10 * [CCDirector sharedDirector ].UIScaleFactor];
678
679
plainTitle.color = [CCColor blackColor ];
679
680
plainTitle.positionType = CCPositionTypeNormalized;
680
- plainTitle.position = ccp (0 .1f , 0 .7f );
681
+ plainTitle.position = ccp (0 .05f , 0 .7f );
681
682
plainTitle.horizontalAlignment = CCTextAlignmentRight;
682
683
683
684
[self .contentNode addChild: plainTitle];
@@ -686,36 +687,40 @@ -(void)setupSpriteColorTest
686
687
CCLabelTTF *effectTitle = [CCLabelTTF labelWithString: @" FX" fontName: @" HelveticaNeue-Light" fontSize: 10 * [CCDirector sharedDirector ].UIScaleFactor];
687
688
effectTitle.color = [CCColor blackColor ];
688
689
effectTitle.positionType = CCPositionTypeNormalized;
689
- effectTitle.position = ccp (0 .1f , 0 .3f );
690
+ effectTitle.position = ccp (0 .05f , 0 .3f );
690
691
effectTitle.horizontalAlignment = CCTextAlignmentRight;
691
692
692
693
[self .contentNode addChild: effectTitle];
693
694
695
+ float x = 0 .15f ;
696
+ float step = 0 .1875f ;
694
697
695
698
// Sprite with solid red
696
699
{
697
700
CCEffect *saturation = [CCEffectSaturation effectWithSaturation: 0 .0f ];
698
701
699
702
CCSprite *plainSprite = [CCSprite spriteWithImageNamed: @" Images/grossini.png" ];
700
703
plainSprite.positionType = CCPositionTypeNormalized;
701
- plainSprite.position = ccp (0 . 2f , 0 .7f );
704
+ plainSprite.position = ccp (x , 0 .7f );
702
705
plainSprite.color = [CCColor redColor ];
703
706
[self .contentNode addChild: plainSprite];
704
707
705
708
CCSprite *effectSprite = [CCSprite spriteWithImageNamed: @" Images/grossini.png" ];
706
709
effectSprite.positionType = CCPositionTypeNormalized;
707
- effectSprite.position = ccp (0 . 2f , 0 .3f );
710
+ effectSprite.position = ccp (x , 0 .3f );
708
711
effectSprite.color = [CCColor redColor ];
709
712
effectSprite.effect = saturation;
710
713
[self .contentNode addChild: effectSprite];
711
714
712
715
CCLabelTTF *title = [CCLabelTTF labelWithString: @" Is color preserved?" fontName: @" HelveticaNeue-Light" fontSize: 10 * [CCDirector sharedDirector ].UIScaleFactor];
713
716
title.color = [CCColor blackColor ];
714
717
title.positionType = CCPositionTypeNormalized;
715
- title.position = ccp (0 . 2f , 0 .05f );
718
+ title.position = ccp (x , 0 .05f );
716
719
title.horizontalAlignment = CCTextAlignmentCenter;
717
720
718
721
[self .contentNode addChild: title];
722
+
723
+ x += step;
719
724
}
720
725
721
726
@@ -725,24 +730,26 @@ -(void)setupSpriteColorTest
725
730
726
731
CCSprite *plainSprite = [CCSprite spriteWithImageNamed: @" Images/grossini.png" ];
727
732
plainSprite.positionType = CCPositionTypeNormalized;
728
- plainSprite.position = ccp (0 . 4f , 0 .7f );
733
+ plainSprite.position = ccp (x , 0 .7f );
729
734
plainSprite.opacity = 0 .5f ;
730
735
[self .contentNode addChild: plainSprite];
731
736
732
737
CCSprite *effectSprite = [CCSprite spriteWithImageNamed: @" Images/grossini.png" ];
733
738
effectSprite.positionType = CCPositionTypeNormalized;
734
- effectSprite.position = ccp (0 . 4f , 0 .3f );
739
+ effectSprite.position = ccp (x , 0 .3f );
735
740
effectSprite.opacity = 0 .5f ;
736
741
effectSprite.effect = saturation;
737
742
[self .contentNode addChild: effectSprite];
738
743
739
744
CCLabelTTF *title = [CCLabelTTF labelWithString: @" Opacity?" fontName: @" HelveticaNeue-Light" fontSize: 10 * [CCDirector sharedDirector ].UIScaleFactor];
740
745
title.color = [CCColor blackColor ];
741
746
title.positionType = CCPositionTypeNormalized;
742
- title.position = ccp (0 . 4f , 0 .05f );
747
+ title.position = ccp (x , 0 .05f );
743
748
title.horizontalAlignment = CCTextAlignmentCenter;
744
749
745
750
[self .contentNode addChild: title];
751
+
752
+ x += step;
746
753
}
747
754
748
755
@@ -755,55 +762,97 @@ -(void)setupSpriteColorTest
755
762
756
763
CCSprite *plainSprite = [CCSprite spriteWithImageNamed: @" Images/grossini.png" ];
757
764
plainSprite.positionType = CCPositionTypeNormalized;
758
- plainSprite.position = ccp (0 . 6f , 0 .7f );
765
+ plainSprite.position = ccp (x , 0 .7f );
759
766
plainSprite.color = [CCColor colorWithRed: 0 .5f green: 0 .0f blue: 0 .0f alpha: 0 .5f ];
760
767
[self .contentNode addChild: plainSprite];
761
768
762
769
CCSprite *effectSprite = [CCSprite spriteWithImageNamed: @" Images/grossini.png" ];
763
770
effectSprite.positionType = CCPositionTypeNormalized;
764
- effectSprite.position = ccp (0 . 6f , 0 .3f );
771
+ effectSprite.position = ccp (x , 0 .3f );
765
772
effectSprite.color = [CCColor colorWithRed: 0 .5f green: 0 .0f blue: 0 .0f alpha: 0 .5f ];
766
773
effectSprite.effect = stack;
767
774
[self .contentNode addChild: effectSprite];
768
775
769
- CCLabelTTF *title = [CCLabelTTF labelWithString: @" Stack (with stitching)" fontName: @" HelveticaNeue-Light" fontSize: 10 * [CCDirector sharedDirector ].UIScaleFactor];
776
+ CCLabelTTF *title = [CCLabelTTF labelWithString: @" Stack (all stitching)" fontName: @" HelveticaNeue-Light" fontSize: 10 * [CCDirector sharedDirector ].UIScaleFactor];
770
777
title.color = [CCColor blackColor ];
771
778
title.positionType = CCPositionTypeNormalized;
772
- title.position = ccp (0 . 6f , 0 .05f );
779
+ title.position = ccp (x , 0 .05f );
773
780
title.horizontalAlignment = CCTextAlignmentCenter;
774
781
775
782
[self .contentNode addChild: title];
783
+
784
+ x += step;
776
785
}
777
786
778
787
779
- // Sprite with 50% transparent red and two stacked effects
788
+ // Sprite with 50% transparent red and three stacked effects but stitching disabled
789
+ // manually after the second effect
780
790
{
781
791
CCEffect *saturation = [CCEffectSaturation effectWithSaturation: 0 .0f ];
792
+ CCEffect *brightness = [CCEffectBrightness effectWithBrightness: 0 .0f ];
782
793
CCEffect *hue = [CCEffectHue effectWithHue: 0 .0f ];
783
794
795
+ // Manually manipulate the brightness effect's stitch flags so it is stitched with
796
+ // saturation but not with hue.
797
+ brightness.stitchFlags = CCEffectFunctionStitchBefore;
798
+
799
+ CCEffectStack *stack = [CCEffectStack effectWithArray: @[saturation, brightness, hue]];
800
+
801
+ CCSprite *plainSprite = [CCSprite spriteWithImageNamed: @" Images/grossini.png" ];
802
+ plainSprite.positionType = CCPositionTypeNormalized;
803
+ plainSprite.position = ccp (x, 0 .7f );
804
+ plainSprite.color = [CCColor colorWithRed: 0 .5f green: 0 .0f blue: 0 .0f alpha: 0 .5f ];
805
+ [self .contentNode addChild: plainSprite];
806
+
807
+ CCSprite *effectSprite = [CCSprite spriteWithImageNamed: @" Images/grossini.png" ];
808
+ effectSprite.positionType = CCPositionTypeNormalized;
809
+ effectSprite.position = ccp (x, 0 .3f );
810
+ effectSprite.color = [CCColor colorWithRed: 0 .5f green: 0 .0f blue: 0 .0f alpha: 0 .5f ];
811
+ effectSprite.effect = stack;
812
+ [self .contentNode addChild: effectSprite];
813
+
814
+ CCLabelTTF *title = [CCLabelTTF labelWithString: @" Stack (some stitching)" fontName: @" HelveticaNeue-Light" fontSize: 10 * [CCDirector sharedDirector ].UIScaleFactor];
815
+ title.color = [CCColor blackColor ];
816
+ title.positionType = CCPositionTypeNormalized;
817
+ title.position = ccp (x, 0 .05f );
818
+ title.horizontalAlignment = CCTextAlignmentCenter;
819
+
820
+ [self .contentNode addChild: title];
821
+
822
+ x += step;
823
+ }
824
+
825
+
826
+ // Sprite with 50% transparent red and two stacked effects but no stitching
827
+ {
828
+ CCEffect *saturation = [CCEffectSaturation effectWithSaturation: 0 .0f ];
829
+ CCEffect *hue = [CCEffectHue effectWithHue: 0 .0f ];
830
+
784
831
CCEffectStack *stack = [CCEffectStack effectWithArray: @[saturation, hue]];
785
832
stack.stitchingEnabled = NO ;
786
833
787
834
CCSprite *plainSprite = [CCSprite spriteWithImageNamed: @" Images/grossini.png" ];
788
835
plainSprite.positionType = CCPositionTypeNormalized;
789
- plainSprite.position = ccp (0 . 8f , 0 .7f );
836
+ plainSprite.position = ccp (x , 0 .7f );
790
837
plainSprite.color = [CCColor colorWithRed: 0 .5f green: 0 .0f blue: 0 .0f alpha: 0 .5f ];
791
838
[self .contentNode addChild: plainSprite];
792
839
793
840
CCSprite *effectSprite = [CCSprite spriteWithImageNamed: @" Images/grossini.png" ];
794
841
effectSprite.positionType = CCPositionTypeNormalized;
795
- effectSprite.position = ccp (0 . 8f , 0 .3f );
842
+ effectSprite.position = ccp (x , 0 .3f );
796
843
effectSprite.color = [CCColor colorWithRed: 0 .5f green: 0 .0f blue: 0 .0f alpha: 0 .5f ];
797
844
effectSprite.effect = stack;
798
845
[self .contentNode addChild: effectSprite];
799
846
800
847
CCLabelTTF *title = [CCLabelTTF labelWithString: @" Stack (no stitching)" fontName: @" HelveticaNeue-Light" fontSize: 10 * [CCDirector sharedDirector ].UIScaleFactor];
801
848
title.color = [CCColor blackColor ];
802
849
title.positionType = CCPositionTypeNormalized;
803
- title.position = ccp (0 . 8f , 0 .05f );
850
+ title.position = ccp (x , 0 .05f );
804
851
title.horizontalAlignment = CCTextAlignmentCenter;
805
852
806
853
[self .contentNode addChild: title];
854
+
855
+ x += step;
807
856
}
808
857
}
809
858
0 commit comments