Skip to content

Commit e4a82a4

Browse files
author
Thayer J Andrews
committed
CCEffectsTest - Add test of effect node parent resizing
1 parent 4ff2432 commit e4a82a4

File tree

1 file changed

+113
-4
lines changed

1 file changed

+113
-4
lines changed

cocos2d-ui-tests/tests/CCEffectsTest.m

Lines changed: 113 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,9 @@ -(void)setupEffectNodeResizeTest
990990
NSArray *subTitles = @[
991991
@"Effect Node Resize Test\nSmall transparent blue node with grossini",
992992
@"Effect Node Resize Test\nMedium transparent blue node with grossini",
993-
@"Effect Node Resize Test\nBig transparent blue node with grossini"
993+
@"Effect Node Resize Test\nBig transparent blue node with grossini",
994+
@"Effect Node Resize Test\nNothing",
995+
@"Effect Node Resize Test\nTransparent blue square with grossini"
994996
];
995997

996998
self.subTitle = subTitles[0];
@@ -1025,10 +1027,117 @@ -(void)setupEffectNodeResizeTest
10251027
__weak CCEffectsTest *weakSelf = self;
10261028
__block NSUInteger callCount = 0;
10271029
CCActionCallBlock *blockAction = [CCActionCallBlock actionWithBlock:^{
1028-
callCount = (callCount + 1) % 3;
1030+
callCount = (callCount + 1) % 5;
10291031

1030-
float nodeSize = 0.25f + 0.25f * callCount;
1031-
effectNode.contentSize = CGSizeMake(nodeSize, nodeSize);
1032+
if (callCount == 0)
1033+
{
1034+
effectNode.contentSizeType = CCSizeTypeNormalized;
1035+
}
1036+
1037+
if (callCount == 3)
1038+
{
1039+
effectNode.contentSizeType = CCSizeTypePoints;
1040+
}
1041+
else if (callCount == 4)
1042+
{
1043+
effectNode.contentSize = CGSizeMake(256.0f, 256.0f);
1044+
}
1045+
else
1046+
{
1047+
float nodeSize = 0.25f + 0.25f * callCount;
1048+
effectNode.contentSize = CGSizeMake(nodeSize, nodeSize);
1049+
}
1050+
1051+
weakSelf.subTitle = subTitles[callCount];
1052+
}];
1053+
[effectNode runAction:[CCActionRepeatForever actionWithAction:[CCActionSequence actions:
1054+
[CCActionDelay actionWithDuration:1.0f],
1055+
blockAction,
1056+
nil
1057+
]]];
1058+
}
1059+
1060+
-(void)setupEffectNodeParentResizeTest
1061+
{
1062+
NSArray *subTitles = @[
1063+
@"Effect Node Parent Resize Test\nSmall transparent red rect with grossini",
1064+
@"Effect Node Parent Resize Test\nMedium transparent red rect with grossini",
1065+
@"Effect Node Parent Resize Test\nBig transparent red rect with grossini",
1066+
@"Effect Node Parent Resize Test\nNothing",
1067+
@"Effect Node Parent Resize Test\nTransparent red square with grossini"
1068+
];
1069+
1070+
self.subTitle = subTitles[0];
1071+
1072+
CCSprite *background = [CCSprite spriteWithImageNamed:@"Images/gridBackground.png"];
1073+
background.positionType = CCPositionTypeNormalized;
1074+
background.position = ccp(0.5f, 0.5f);
1075+
[self.contentNode addChild:background];
1076+
1077+
1078+
CCNode *grandparent = [[CCNode alloc] init];
1079+
grandparent.contentSizeType = CCSizeTypeNormalized;
1080+
grandparent.contentSize = CGSizeMake(0.25f, 0.25f);
1081+
grandparent.anchorPoint = ccp(0.5f, 0.5f);
1082+
grandparent.positionType = CCPositionTypeNormalized;
1083+
grandparent.position = ccp(0.5f, 0.5f);
1084+
[self.contentNode addChild:grandparent];
1085+
1086+
1087+
CCNode *parent = [[CCNode alloc] init];
1088+
parent.contentSizeType = CCSizeTypeNormalized;
1089+
parent.contentSize = CGSizeMake(1.0f, 1.0f);
1090+
parent.anchorPoint = ccp(0.5f, 0.5f);
1091+
parent.positionType = CCPositionTypeNormalized;
1092+
parent.position = ccp(0.5f, 0.5f);
1093+
[grandparent addChild:parent];
1094+
1095+
1096+
CCEffectNode *effectNode = [[CCEffectNode alloc] init];
1097+
effectNode.clearFlags = GL_COLOR_BUFFER_BIT;
1098+
effectNode.clearColor = [CCColor colorWithRed:0.0f green:0.0f blue:0.5f alpha:0.5f];
1099+
effectNode.contentSizeType = CCSizeTypeNormalized;
1100+
effectNode.contentSize = CGSizeMake(1.0f, 1.0f);
1101+
effectNode.anchorPoint = ccp(0.5f, 0.5f);
1102+
effectNode.positionType = CCPositionTypeNormalized;
1103+
effectNode.position = ccp(0.5f, 0.5f);
1104+
1105+
CCEffectHue *effect = [CCEffectHue effectWithHue:120.0f];
1106+
effectNode.effect = effect;
1107+
1108+
[parent addChild:effectNode];
1109+
1110+
1111+
CCSprite *sprite = [CCSprite spriteWithImageNamed:@"Images/grossini.png"];
1112+
sprite.anchorPoint = ccp(0.5, 0.5);
1113+
sprite.positionType = CCPositionTypeNormalized;
1114+
sprite.position = ccp(0.5f, 0.5f);
1115+
[effectNode addChild:sprite];
1116+
1117+
1118+
__weak CCEffectsTest *weakSelf = self;
1119+
__block NSUInteger callCount = 0;
1120+
CCActionCallBlock *blockAction = [CCActionCallBlock actionWithBlock:^{
1121+
callCount = (callCount + 1) % 5;
1122+
1123+
if (callCount == 0)
1124+
{
1125+
grandparent.contentSizeType = CCSizeTypeNormalized;
1126+
}
1127+
1128+
if (callCount == 3)
1129+
{
1130+
grandparent.contentSizeType = CCSizeTypePoints;
1131+
}
1132+
else if (callCount == 4)
1133+
{
1134+
grandparent.contentSize = CGSizeMake(256.0f, 256.0f);
1135+
}
1136+
else
1137+
{
1138+
float grandparentSize = 0.25f + 0.25f * callCount;
1139+
grandparent.contentSize = CGSizeMake(grandparentSize, grandparentSize);
1140+
}
10321141

10331142
weakSelf.subTitle = subTitles[callCount];
10341143
}];

0 commit comments

Comments
 (0)