@@ -251,6 +251,151 @@ - (void)enableOutline:(id)sender
251
251
252
252
#endif
253
253
254
+ -(void )setupPaddingEffectTest
255
+ {
256
+ self.subTitle = @" Effect Padding Test" ;
257
+
258
+ {
259
+ CCSprite *sprite = [CCSprite spriteWithImageNamed: @" Images/particles.png" ];
260
+ sprite.positionType = CCPositionTypeNormalized;
261
+ sprite.position = ccp (0 .75f , 0 .8f );
262
+
263
+ [self .contentNode addChild: sprite];
264
+
265
+ CCLabelTTF *title = [CCLabelTTF labelWithString: @" Original Sprite" fontName: @" HelveticaNeue-Light" fontSize: 14 * [CCDirector sharedDirector ].UIScaleFactor];
266
+ title.color = [CCColor whiteColor ];
267
+ title.positionType = CCPositionTypeNormalized;
268
+ title.position = ccp (0 .25f , 0 .8f );
269
+ title.horizontalAlignment = CCTextAlignmentCenter;
270
+
271
+ [self .contentNode addChild: title];
272
+ }
273
+
274
+ {
275
+ CCSprite *sprite = [CCSprite spriteWithImageNamed: @" Images/particles.png" ];
276
+ sprite.positionType = CCPositionTypeNormalized;
277
+ sprite.position = ccp (0 .75f , 0 .65f );
278
+
279
+ CCEffectColorChannelOffset *offset = [CCEffectColorChannelOffset effectWithRedOffset: GLKVector2Make (5 .0f , 0 .0f ) greenOffset: GLKVector2Make (-4 .0f , 4 .0f ) blueOffset: GLKVector2Make (-4 .0f , -4 .0f )];
280
+ sprite.effect = offset;
281
+
282
+ [self .contentNode addChild: sprite];
283
+
284
+ CCLabelTTF *title = [CCLabelTTF labelWithString: @" Color channel offset without padding" fontName: @" HelveticaNeue-Light" fontSize: 14 * [CCDirector sharedDirector ].UIScaleFactor];
285
+ title.color = [CCColor whiteColor ];
286
+ title.positionType = CCPositionTypeNormalized;
287
+ title.position = ccp (0 .25f , 0 .65f );
288
+ title.horizontalAlignment = CCTextAlignmentCenter;
289
+
290
+ [self .contentNode addChild: title];
291
+ }
292
+
293
+ {
294
+ CCSprite *sprite = [CCSprite spriteWithImageNamed: @" Images/particles.png" ];
295
+ sprite.positionType = CCPositionTypeNormalized;
296
+ sprite.position = ccp (0 .75f , 0 .5f );
297
+
298
+ CCEffectColorChannelOffset *offset = [CCEffectColorChannelOffset effectWithRedOffset: GLKVector2Make (5 .0f , 0 .0f ) greenOffset: GLKVector2Make (-4 .0f , 4 .0f ) blueOffset: GLKVector2Make (-4 .0f , -4 .0f )];
299
+ offset.padding = CGSizeMake (5 .0f , 5 .0f );
300
+ sprite.effect = offset;
301
+
302
+ [self .contentNode addChild: sprite];
303
+
304
+ CCLabelTTF *title = [CCLabelTTF labelWithString: @" Color channel offset with padding" fontName: @" HelveticaNeue-Light" fontSize: 14 * [CCDirector sharedDirector ].UIScaleFactor];
305
+ title.color = [CCColor whiteColor ];
306
+ title.positionType = CCPositionTypeNormalized;
307
+ title.position = ccp (0 .25f , 0 .5f );
308
+ title.horizontalAlignment = CCTextAlignmentCenter;
309
+
310
+ [self .contentNode addChild: title];
311
+ }
312
+
313
+ {
314
+ CCSprite *sprite = [CCSprite spriteWithImageNamed: @" Images/particles.png" ];
315
+ sprite.positionType = CCPositionTypeNormalized;
316
+ sprite.position = ccp (0 .75f , 0 .35f );
317
+
318
+ CCEffectColorChannelOffset *offset = [CCEffectColorChannelOffset effectWithRedOffset: GLKVector2Make (5 .0f , 0 .0f ) greenOffset: GLKVector2Make (-4 .0f , 4 .0f ) blueOffset: GLKVector2Make (-4 .0f , -4 .0f )];
319
+ offset.padding = CGSizeMake (5 .0f , 5 .0f );
320
+ CCEffectHue *hue = [CCEffectHue effectWithHue: 60 .0f ];
321
+ sprite.effect = [CCEffectStack effectWithArray: @[offset, hue]];
322
+
323
+ [self .contentNode addChild: sprite];
324
+
325
+ CCLabelTTF *title = [CCLabelTTF labelWithString: @" Padded effect stack (offset then hue)" fontName: @" HelveticaNeue-Light" fontSize: 14 * [CCDirector sharedDirector ].UIScaleFactor];
326
+ title.color = [CCColor whiteColor ];
327
+ title.positionType = CCPositionTypeNormalized;
328
+ title.position = ccp (0 .25f , 0 .35f );
329
+ title.horizontalAlignment = CCTextAlignmentCenter;
330
+
331
+ [self .contentNode addChild: title];
332
+ }
333
+
334
+ {
335
+ CCSprite *sprite = [CCSprite spriteWithImageNamed: @" Images/particles.png" ];
336
+ sprite.positionType = CCPositionTypeNormalized;
337
+ sprite.position = ccp (0 .75f , 0 .2f );
338
+
339
+ CCEffectColorChannelOffset *offset = [CCEffectColorChannelOffset effectWithRedOffset: GLKVector2Make (5 .0f , 0 .0f ) greenOffset: GLKVector2Make (-4 .0f , 4 .0f ) blueOffset: GLKVector2Make (-4 .0f , -4 .0f )];
340
+ offset.padding = CGSizeMake (5 .0f , 5 .0f );
341
+ CCEffectHue *hue = [CCEffectHue effectWithHue: 60 .0f ];
342
+ sprite.effect = [CCEffectStack effectWithArray: @[hue, offset]];
343
+
344
+ [self .contentNode addChild: sprite];
345
+
346
+ CCLabelTTF *title = [CCLabelTTF labelWithString: @" Padded efect stack (hue then offset)" fontName: @" HelveticaNeue-Light" fontSize: 14 * [CCDirector sharedDirector ].UIScaleFactor];
347
+ title.color = [CCColor whiteColor ];
348
+ title.positionType = CCPositionTypeNormalized;
349
+ title.position = ccp (0 .25f , 0 .2f );
350
+ title.horizontalAlignment = CCTextAlignmentCenter;
351
+
352
+ [self .contentNode addChild: title];
353
+ }
354
+ }
355
+
356
+ -(void )setupColorChannelOffsetTest
357
+ {
358
+ self.subTitle = @" Color Channel Offset Effect Test" ;
359
+
360
+ CCEffectColorChannelOffset *effect = [CCEffectColorChannelOffset effectWithRedOffset: GLKVector2Make (0 .0f , 0 .0f ) greenOffset: GLKVector2Make (0 .0f , 0 .0f ) blueOffset: GLKVector2Make (0 .0f , 0 .0f )];
361
+ effect.padding = CGSizeMake (5 .0f , 5 .0f );
362
+
363
+ CCSprite *sprite = [CCSprite spriteWithImageNamed: @" Images/particles.png" ];
364
+ sprite.scale = 1 .0f ;
365
+ sprite.positionType = CCPositionTypeNormalized;
366
+ sprite.position = ccp (0 .5f , 0 .5f );
367
+ sprite.effect = effect;
368
+
369
+ [self .contentNode addChild: sprite];
370
+
371
+ const float thetaStep = CC_DEGREES_TO_RADIANS (10 .0f );
372
+ __block float redTheta = CC_DEGREES_TO_RADIANS (0 .0f );
373
+ __block float greenTheta = CC_DEGREES_TO_RADIANS (120 .0f );
374
+ __block float blueTheta = CC_DEGREES_TO_RADIANS (240 .0f );
375
+ void (^updateBlock)() = ^{
376
+
377
+ float redRadius = 3 .0f ;
378
+ effect.redOffset = GLKVector2Make (redRadius * cosf (redTheta), redRadius * sinf (redTheta));
379
+
380
+ float greenRadius = 3 .0f ;
381
+ effect.greenOffset = GLKVector2Make (greenRadius * cosf (greenTheta), greenRadius * sinf (greenTheta));
382
+
383
+ float blueRadius = 3 .0f ;
384
+ effect.blueOffset = GLKVector2Make (blueRadius * cosf (blueTheta), blueRadius * sinf (blueTheta));
385
+
386
+ redTheta += thetaStep;
387
+ greenTheta += thetaStep;
388
+ blueTheta += thetaStep;
389
+ };
390
+ updateBlock ();
391
+
392
+ [sprite runAction: [CCActionRepeatForever actionWithAction: [CCActionSequence actions:
393
+ [CCActionDelay actionWithDuration: 0 .1f ],
394
+ [CCActionCallBlock actionWithBlock: updateBlock],
395
+ nil
396
+ ]]];
397
+ }
398
+
254
399
#pragma mark DropShadow
255
400
256
401
-(void )setupDropShadowEffectTest
@@ -659,13 +804,14 @@ -(void)setupBloomEffectTest
659
804
const int steps = 5 ;
660
805
for (int i = 0 ; i < steps; i++)
661
806
{
662
- CCSprite *sampleSprite3 = [CCSprite spriteWithImageNamed: @" Images/grossini_dance_08 .png" ];
807
+ CCSprite *sampleSprite3 = [CCSprite spriteWithImageNamed: @" Images/f1 .png" ];
663
808
sampleSprite3.anchorPoint = ccp (0.5 , 0.5 );
664
809
sampleSprite3.position = ccp (0 .1f + i * (0 .8f / (steps - 1 )), 0 .2f );
665
810
sampleSprite3.positionType = CCPositionTypeNormalized;
666
811
667
812
// Blend glow maps test
668
- CCEffectBloom* glowEffect3 = [CCEffectBloom effectWithBlurRadius: 3 intensity: 1 .0f luminanceThreshold: 1 .0f - ((float )i/(float )(steps-1 ))];
813
+ CCEffectBloom* glowEffect3 = [CCEffectBloom effectWithBlurRadius: 8 intensity: 1 .0f luminanceThreshold: 1 .0f - ((float )i/(float )(steps-1 ))];
814
+ glowEffect3.padding = CGSizeMake (10 .0f , 10 .0f );
669
815
sampleSprite3.effect = glowEffect3;
670
816
671
817
[self .contentNode addChild: sampleSprite3];
0 commit comments