@@ -251,6 +251,48 @@ - (void)enableOutline:(id)sender
251
251
252
252
#endif
253
253
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
+
254
296
-(void )setupPaddingEffectTest
255
297
{
256
298
self.subTitle = @" Effect Padding Test" ;
0 commit comments