Skip to content

Commit 864470c

Browse files
author
Thayer J Andrews
committed
CCEffectsTest - Tweak the simple lighting test
Change the node hierarchy around a bit so the sprite can be scaled independently of other nodes in the test scene.
1 parent a33f8d2 commit 864470c

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

cocos2d-ui-tests/tests/CCEffectsTest.m

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -269,29 +269,35 @@ -(void)setupSimpleLightingTest
269269
light.depth = lightDepth;
270270

271271
CCSprite *lightSprite = [CCSprite spriteWithImageNamed:@"Images/snow.png"];
272-
[light addChild:lightSprite];
273272

274273
CCEffectLighting *lightingEffect = [[CCEffectLighting alloc] initWithLights:@[light]];
275274
lightingEffect.shininess = 10.0f;
276275

277276
CCSprite *sprite = [CCSprite spriteWithImageNamed:diffuseImage];
278277
sprite.positionType = CCPositionTypeNormalized;
279-
sprite.position = position;
278+
sprite.position = ccp(0.5f, 0.5f);
280279
sprite.normalMapSpriteFrame = [CCSpriteFrame frameWithImageNamed:normalMapImage];
281280
sprite.effect = lightingEffect;
282281
sprite.scale = 0.5f;
283282

284-
[self.contentNode addChild:sprite];
285-
286-
[sprite addChild:light];
287-
288-
CCLabelTTF *label = [CCLabelTTF labelWithString:title fontName:@"HelveticaNeue-Light" fontSize:18 * [CCDirector sharedDirector].UIScaleFactor];
283+
CCNode *root = [[CCNode alloc] init];
284+
root.positionType = CCPositionTypeNormalized;
285+
root.position = position;
286+
root.anchorPoint = ccp(0.5f, 0.5f);
287+
root.contentSizeType = CCSizeTypePoints;
288+
root.contentSize = CGSizeMake(200.0f, 200.0f);
289+
290+
CCLabelTTF *label = [CCLabelTTF labelWithString:title fontName:@"HelveticaNeue-Light" fontSize:12 * [CCDirector sharedDirector].UIScaleFactor];
289291
label.color = [CCColor whiteColor];
290292
label.positionType = CCPositionTypeNormalized;
291-
label.position = ccp(0.5f, 1.1f);
293+
label.position = ccp(0.5f, 1.0f);
292294
label.horizontalAlignment = CCTextAlignmentCenter;
293295

294-
[sprite addChild:label];
296+
[self.contentNode addChild:root];
297+
[root addChild:label];
298+
[root addChild:sprite];
299+
[root addChild:light];
300+
[light addChild:lightSprite];
295301

296302
[light runAction:[CCActionRepeatForever actionWithAction:[CCActionSequence actions:
297303
[CCActionMoveTo actionWithDuration:1.0 position:ccp(1.0f, 1.0f)],

0 commit comments

Comments
 (0)