@@ -656,6 +656,190 @@ -(void)setupPerformanceTest
656
656
NSLog (@" setupPerformanceTest: Laid out %d sprites." , count);
657
657
}
658
658
659
+ -(void )setupEffectNodeAnchorTest
660
+ {
661
+ self.subTitle = @" Effect Node Anchor Point Test\n Transparent RGB quads from lower-left to upper-right." ;
662
+
663
+ CCSprite *background = [CCSprite spriteWithImageNamed: @" Images/gridBackground.png" ];
664
+ background.positionType = CCPositionTypeNormalized;
665
+ background.position = ccp (0 .5f , 0 .5f );
666
+ [self .contentNode addChild: background];
667
+
668
+ {
669
+ CCEffectNode* effectNode = [[CCEffectNode alloc ] init ];
670
+ effectNode.clearFlags = GL_COLOR_BUFFER_BIT;
671
+ effectNode.clearColor = [CCColor colorWithRed: 0 .5f green: 0 .0f blue: 0 .0f alpha: 0 .5f ];
672
+ effectNode.contentSize = CGSizeMake (80 , 80 );
673
+ effectNode.anchorPoint = ccp (1.0 , 1.0 );
674
+ effectNode.positionType = CCPositionTypeNormalized;
675
+ effectNode.position = ccp (0.5 , 0.5 );
676
+
677
+ CCEffectHue *effect = [CCEffectHue effectWithHue: 0 .0f ];
678
+ effectNode.effect = effect;
679
+
680
+ [self .contentNode addChild: effectNode];
681
+ }
682
+
683
+ {
684
+ CCEffectNode* effectNode = [[CCEffectNode alloc ] init ];
685
+ effectNode.clearFlags = GL_COLOR_BUFFER_BIT;
686
+ effectNode.clearColor = [CCColor colorWithRed: 0 .5f green: 0 .0f blue: 0 .0f alpha: 0 .5f ];
687
+ effectNode.contentSize = CGSizeMake (80 , 80 );
688
+ effectNode.anchorPoint = ccp (0.5 , 0.5 );
689
+ effectNode.positionType = CCPositionTypeNormalized;
690
+ effectNode.position = ccp (0.5 , 0.5 );
691
+
692
+ CCEffectHue *effect = [CCEffectHue effectWithHue: 120 .0f ];
693
+ effectNode.effect = effect;
694
+
695
+ [self .contentNode addChild: effectNode];
696
+ }
697
+
698
+ {
699
+ CCEffectNode* effectNode = [[CCEffectNode alloc ] init ];
700
+ effectNode.clearFlags = GL_COLOR_BUFFER_BIT;
701
+ effectNode.clearColor = [CCColor colorWithRed: 0 .5f green: 0 .0f blue: 0 .0f alpha: 0 .5f ];
702
+ effectNode.contentSize = CGSizeMake (80 , 80 );
703
+ effectNode.anchorPoint = ccp (0.0 , 0.0 );
704
+ effectNode.positionType = CCPositionTypeNormalized;
705
+ effectNode.position = ccp (0.5 , 0.5 );
706
+
707
+ CCEffectHue *effect = [CCEffectHue effectWithHue: -120 .0f ];
708
+ effectNode.effect = effect;
709
+
710
+ [self .contentNode addChild: effectNode];
711
+ }
712
+ }
713
+
714
+ -(void )setupEffectNodeSizeTypeTest
715
+ {
716
+ self.subTitle = @" Effect Node Size Type Test\n Small red and big blue transparent quads.\n Red bar on left. Green bar on bottom." ;
717
+
718
+ CCSprite *background = [CCSprite spriteWithImageNamed: @" Images/gridBackground.png" ];
719
+ background.positionType = CCPositionTypeNormalized;
720
+ background.position = ccp (0 .5f , 0 .5f );
721
+ [self .contentNode addChild: background];
722
+
723
+ {
724
+ CCEffectNode* effectNode = [[CCEffectNode alloc ] init ];
725
+ effectNode.clearFlags = GL_COLOR_BUFFER_BIT;
726
+ effectNode.clearColor = [CCColor colorWithRed: 0 .5f green: 0 .0f blue: 0 .0f alpha: 0 .5f ];
727
+ effectNode.contentSizeType = CCSizeTypeNormalized;
728
+ effectNode.contentSize = CGSizeMake (0 .5f , 0 .5f );
729
+ effectNode.anchorPoint = ccp (0 .5f , 0 .5f );
730
+ effectNode.positionType = CCPositionTypeNormalized;
731
+ effectNode.position = ccp (0 .5f , 0 .5f );
732
+
733
+ CCEffectHue *effect = [CCEffectHue effectWithHue: -120 .0f ];
734
+ effectNode.effect = effect;
735
+
736
+ [self .contentNode addChild: effectNode];
737
+ }
738
+
739
+ {
740
+ CCEffectNode* effectNode = [[CCEffectNode alloc ] init ];
741
+ effectNode.clearFlags = GL_COLOR_BUFFER_BIT;
742
+ effectNode.clearColor = [CCColor colorWithRed: 0 .5f green: 0 .0f blue: 0 .0f alpha: 0 .5f ];
743
+ effectNode.contentSizeType = CCSizeTypePoints;
744
+ effectNode.contentSize = CGSizeMake (80 .0f , 80 .0f );
745
+ effectNode.anchorPoint = ccp (0 .5f , 0 .5f );
746
+ effectNode.positionType = CCPositionTypeNormalized;
747
+ effectNode.position = ccp (0 .5f , 0 .5f );
748
+
749
+ CCEffectHue *effect = [CCEffectHue effectWithHue: 0 .0f ];
750
+ effectNode.effect = effect;
751
+
752
+ [self .contentNode addChild: effectNode];
753
+ }
754
+
755
+ {
756
+ CCEffectNode* effectNode = [[CCEffectNode alloc ] init ];
757
+ effectNode.clearFlags = GL_COLOR_BUFFER_BIT;
758
+ effectNode.clearColor = [CCColor colorWithRed: 1 .0f green: 0 .0f blue: 0 .0f alpha: 1 .0f ];
759
+ effectNode.contentSizeType = CCSizeTypeMake (CCSizeUnitPoints, CCSizeUnitNormalized);
760
+ effectNode.contentSize = CGSizeMake (20 .0f , 0 .9f );
761
+ effectNode.anchorPoint = ccp (0 .0f , 0 .0f );
762
+ effectNode.positionType = CCPositionTypeNormalized;
763
+ effectNode.position = ccp (0 .05f , 0 .05f );
764
+
765
+ CCEffectHue *effect = [CCEffectHue effectWithHue: 0 .0f ];
766
+ effectNode.effect = effect;
767
+
768
+ [self .contentNode addChild: effectNode];
769
+ }
770
+
771
+ {
772
+ CCEffectNode* effectNode = [[CCEffectNode alloc ] init ];
773
+ effectNode.clearFlags = GL_COLOR_BUFFER_BIT;
774
+ effectNode.clearColor = [CCColor colorWithRed: 1 .0f green: 0 .0f blue: 0 .0f alpha: 1 .0f ];
775
+ effectNode.contentSizeType = CCSizeTypeMake (CCSizeUnitNormalized, CCSizeUnitPoints);
776
+ effectNode.contentSize = CGSizeMake (0 .9f , 20 .0f );
777
+ effectNode.anchorPoint = ccp (0 .0f , 0 .0f );
778
+ effectNode.positionType = CCPositionTypeNormalized;
779
+ effectNode.position = ccp (0 .05f , 0 .05f );
780
+
781
+ CCEffectHue *effect = [CCEffectHue effectWithHue: 120 .0f ];
782
+ effectNode.effect = effect;
783
+
784
+ [self .contentNode addChild: effectNode];
785
+ }
786
+ }
787
+
788
+ -(void )setupEffectNodeChildPositioningTest
789
+ {
790
+ self.subTitle = @" Effect Node Child Positioning Test\n Big transparent purple quad and small opaque green quad (both with grossini).\n " ;
791
+
792
+ CCSprite *background = [CCSprite spriteWithImageNamed: @" Images/gridBackground.png" ];
793
+ background.positionType = CCPositionTypeNormalized;
794
+ background.position = ccp (0 .5f , 0 .5f );
795
+ [self .contentNode addChild: background];
796
+
797
+ {
798
+ CCEffectNode* effectNode = [[CCEffectNode alloc ] init ];
799
+ effectNode.clearFlags = GL_COLOR_BUFFER_BIT;
800
+ effectNode.clearColor = [CCColor colorWithRed: 0 .5f green: 0 .0f blue: 0 .0f alpha: 0 .5f ];
801
+ effectNode.contentSizeType = CCSizeTypeNormalized;
802
+ effectNode.contentSize = CGSizeMake (0.75 , 0.75 );
803
+ effectNode.anchorPoint = ccp (0.5 , 0.5 );
804
+ effectNode.positionType = CCPositionTypeNormalized;
805
+ effectNode.position = ccp (0.5 , 0.5 );
806
+
807
+ CCEffectHue *effect = [CCEffectHue effectWithHue: -60 .0f ];
808
+ effectNode.effect = effect;
809
+
810
+ [self .contentNode addChild: effectNode];
811
+
812
+ CCSprite *sprite = [CCSprite spriteWithImageNamed: @" Images/grossini.png" ];
813
+ sprite.anchorPoint = ccp (0.5 , 0.5 );
814
+ sprite.positionType = CCPositionTypeNormalized;
815
+ sprite.position = ccp (0 .25f , 0 .5f );
816
+ [effectNode addChild: sprite];
817
+ }
818
+
819
+ {
820
+ CCEffectNode* effectNode = [[CCEffectNode alloc ] init ];
821
+ effectNode.clearFlags = GL_COLOR_BUFFER_BIT;
822
+ effectNode.clearColor = [CCColor colorWithRed: 1 .0f green: 0 .0f blue: 0 .0f alpha: 1 .0f ];
823
+ effectNode.contentSizeType = CCSizeTypeMake (CCSizeUnitPoints, CCSizeUnitNormalized);
824
+ effectNode.contentSize = CGSizeMake (128 , 0.5 );
825
+ effectNode.anchorPoint = ccp (0.5 , 0.5 );
826
+ effectNode.positionType = CCPositionTypeNormalized;
827
+ effectNode.position = ccp (0.75 , 0.5 );
828
+
829
+ CCEffectHue *effect = [CCEffectHue effectWithHue: 120 .0f ];
830
+ effectNode.effect = effect;
831
+
832
+ [self .contentNode addChild: effectNode];
833
+
834
+ CCSprite *sprite = [CCSprite spriteWithImageNamed: @" Images/grossini.png" ];
835
+ sprite.anchorPoint = ccp (0.5 , 0.5 );
836
+ sprite.positionType = CCPositionTypeNormalized;
837
+ sprite.position = ccp (0 .5f , 0 .5f );
838
+ [effectNode addChild: sprite];
839
+ }
840
+ }
841
+
842
+
659
843
- (CCNode *)effectNodeWithEffects : (NSArray *)effects appliedToSpriteWithImage : (NSString *)spriteImage atPosition : (CGPoint)position
660
844
{
661
845
// Another sprite that will be added directly
0 commit comments