Skip to content

Commit 21cb873

Browse files
author
Thayer J Andrews
committed
CCEffectsTest - Simple point lighting test
1 parent e6e9b9c commit 21cb873

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

cocos2d-ui-tests/tests/CCEffectsTest.m

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,48 @@ - (void)enableOutline:(id)sender
251251

252252
#endif
253253

254+
-(void)setupLightingEffectTest
255+
{
256+
self.subTitle = @"Lighting Effect Test";
257+
258+
NSString *normalMapImage = @"Images/ShinyTorusNormals.png";
259+
NSString *diffuseImage = @"Images/ShinyTorusColor.png";
260+
261+
CCLightNode *light = [[CCLightNode alloc] init];
262+
light.positionType = CCPositionTypePoints;
263+
light.position = ccp(100.0f, 0.0f);
264+
light.anchorPoint = ccp(0.5f, 0.5f);
265+
light.intensity = 1.0f;
266+
light.ambientIntensity = 0.2f;
267+
light.cutoffRadius = 0.0f;
268+
light.depth = 250.0f;
269+
270+
CCSprite *lightSprite = [CCSprite spriteWithImageNamed:@"Images/snow.png"];
271+
[light addChild:lightSprite];
272+
273+
CCNode *node = [[CCNode alloc] init];
274+
node.positionType = CCPositionTypeNormalized;
275+
node.position = ccp(0.65f, 0.5f);
276+
node.anchorPoint = ccp(0.5f, 0.5f);
277+
278+
[node addChild:light];
279+
280+
CCEffectLighting *lightingEffect = [[CCEffectLighting alloc] initWithLights:@[light]];
281+
282+
CCSprite *sprite = [CCSprite spriteWithImageNamed:diffuseImage];
283+
sprite.positionType = CCPositionTypeNormalized;
284+
sprite.position = ccp(0.5f, 0.5f);
285+
sprite.normalMapSpriteFrame = [CCSpriteFrame frameWithImageNamed:normalMapImage];
286+
sprite.effect = lightingEffect;
287+
sprite.scale = 0.5f;
288+
289+
[self.contentNode addChild:sprite];
290+
[self.contentNode addChild:node];
291+
292+
[node runAction:[CCActionRepeatForever actionWithAction:[CCActionRotateBy actionWithDuration:1.0 angle:45.0]]];
293+
[light runAction:[CCActionRepeatForever actionWithAction:[CCActionRotateBy actionWithDuration:1.0 angle:-45.0]]];
294+
}
295+
254296
-(void)setupPaddingEffectTest
255297
{
256298
self.subTitle = @"Effect Padding Test";

0 commit comments

Comments
 (0)