@@ -200,6 +200,151 @@ - (void)enableOutline:(id)sender
200200
201201#endif
202202
203+ -(void )setupPaddingEffectTest
204+ {
205+ self.subTitle = @" Effect Padding Test" ;
206+
207+ {
208+ CCSprite *sprite = [CCSprite spriteWithImageNamed: @" Images/particles.png" ];
209+ sprite.positionType = CCPositionTypeNormalized;
210+ sprite.position = ccp (0 .75f , 0 .8f );
211+
212+ [self .contentNode addChild: sprite];
213+
214+ CCLabelTTF *title = [CCLabelTTF labelWithString: @" Original Sprite" fontName: @" HelveticaNeue-Light" fontSize: 14 * [CCDirector sharedDirector ].UIScaleFactor];
215+ title.color = [CCColor whiteColor ];
216+ title.positionType = CCPositionTypeNormalized;
217+ title.position = ccp (0 .25f , 0 .8f );
218+ title.horizontalAlignment = CCTextAlignmentCenter;
219+
220+ [self .contentNode addChild: title];
221+ }
222+
223+ {
224+ CCSprite *sprite = [CCSprite spriteWithImageNamed: @" Images/particles.png" ];
225+ sprite.positionType = CCPositionTypeNormalized;
226+ sprite.position = ccp (0 .75f , 0 .65f );
227+
228+ CCEffectColorChannelOffset *offset = [CCEffectColorChannelOffset effectWithRedOffset: GLKVector2Make (5 .0f , 0 .0f ) greenOffset: GLKVector2Make (-4 .0f , 4 .0f ) blueOffset: GLKVector2Make (-4 .0f , -4 .0f )];
229+ sprite.effect = offset;
230+
231+ [self .contentNode addChild: sprite];
232+
233+ CCLabelTTF *title = [CCLabelTTF labelWithString: @" Color channel offset without padding" fontName: @" HelveticaNeue-Light" fontSize: 14 * [CCDirector sharedDirector ].UIScaleFactor];
234+ title.color = [CCColor whiteColor ];
235+ title.positionType = CCPositionTypeNormalized;
236+ title.position = ccp (0 .25f , 0 .65f );
237+ title.horizontalAlignment = CCTextAlignmentCenter;
238+
239+ [self .contentNode addChild: title];
240+ }
241+
242+ {
243+ CCSprite *sprite = [CCSprite spriteWithImageNamed: @" Images/particles.png" ];
244+ sprite.positionType = CCPositionTypeNormalized;
245+ sprite.position = ccp (0 .75f , 0 .5f );
246+
247+ CCEffectColorChannelOffset *offset = [CCEffectColorChannelOffset effectWithRedOffset: GLKVector2Make (5 .0f , 0 .0f ) greenOffset: GLKVector2Make (-4 .0f , 4 .0f ) blueOffset: GLKVector2Make (-4 .0f , -4 .0f )];
248+ offset.padding = CGSizeMake (5 .0f , 5 .0f );
249+ sprite.effect = offset;
250+
251+ [self .contentNode addChild: sprite];
252+
253+ CCLabelTTF *title = [CCLabelTTF labelWithString: @" Color channel offset with padding" fontName: @" HelveticaNeue-Light" fontSize: 14 * [CCDirector sharedDirector ].UIScaleFactor];
254+ title.color = [CCColor whiteColor ];
255+ title.positionType = CCPositionTypeNormalized;
256+ title.position = ccp (0 .25f , 0 .5f );
257+ title.horizontalAlignment = CCTextAlignmentCenter;
258+
259+ [self .contentNode addChild: title];
260+ }
261+
262+ {
263+ CCSprite *sprite = [CCSprite spriteWithImageNamed: @" Images/particles.png" ];
264+ sprite.positionType = CCPositionTypeNormalized;
265+ sprite.position = ccp (0 .75f , 0 .35f );
266+
267+ CCEffectColorChannelOffset *offset = [CCEffectColorChannelOffset effectWithRedOffset: GLKVector2Make (5 .0f , 0 .0f ) greenOffset: GLKVector2Make (-4 .0f , 4 .0f ) blueOffset: GLKVector2Make (-4 .0f , -4 .0f )];
268+ offset.padding = CGSizeMake (5 .0f , 5 .0f );
269+ CCEffectHue *hue = [CCEffectHue effectWithHue: 60 .0f ];
270+ sprite.effect = [CCEffectStack effectWithArray: @[offset, hue]];
271+
272+ [self .contentNode addChild: sprite];
273+
274+ CCLabelTTF *title = [CCLabelTTF labelWithString: @" Padded effect stack (offset then hue)" fontName: @" HelveticaNeue-Light" fontSize: 14 * [CCDirector sharedDirector ].UIScaleFactor];
275+ title.color = [CCColor whiteColor ];
276+ title.positionType = CCPositionTypeNormalized;
277+ title.position = ccp (0 .25f , 0 .35f );
278+ title.horizontalAlignment = CCTextAlignmentCenter;
279+
280+ [self .contentNode addChild: title];
281+ }
282+
283+ {
284+ CCSprite *sprite = [CCSprite spriteWithImageNamed: @" Images/particles.png" ];
285+ sprite.positionType = CCPositionTypeNormalized;
286+ sprite.position = ccp (0 .75f , 0 .2f );
287+
288+ CCEffectColorChannelOffset *offset = [CCEffectColorChannelOffset effectWithRedOffset: GLKVector2Make (5 .0f , 0 .0f ) greenOffset: GLKVector2Make (-4 .0f , 4 .0f ) blueOffset: GLKVector2Make (-4 .0f , -4 .0f )];
289+ offset.padding = CGSizeMake (5 .0f , 5 .0f );
290+ CCEffectHue *hue = [CCEffectHue effectWithHue: 60 .0f ];
291+ sprite.effect = [CCEffectStack effectWithArray: @[hue, offset]];
292+
293+ [self .contentNode addChild: sprite];
294+
295+ CCLabelTTF *title = [CCLabelTTF labelWithString: @" Padded efect stack (hue then offset)" fontName: @" HelveticaNeue-Light" fontSize: 14 * [CCDirector sharedDirector ].UIScaleFactor];
296+ title.color = [CCColor whiteColor ];
297+ title.positionType = CCPositionTypeNormalized;
298+ title.position = ccp (0 .25f , 0 .2f );
299+ title.horizontalAlignment = CCTextAlignmentCenter;
300+
301+ [self .contentNode addChild: title];
302+ }
303+ }
304+
305+ -(void )setupColorChannelOffsetTest
306+ {
307+ self.subTitle = @" Color Channel Offset Effect Test" ;
308+
309+ CCEffectColorChannelOffset *effect = [CCEffectColorChannelOffset effectWithRedOffset: GLKVector2Make (0 .0f , 0 .0f ) greenOffset: GLKVector2Make (0 .0f , 0 .0f ) blueOffset: GLKVector2Make (0 .0f , 0 .0f )];
310+ effect.padding = CGSizeMake (5 .0f , 5 .0f );
311+
312+ CCSprite *sprite = [CCSprite spriteWithImageNamed: @" Images/particles.png" ];
313+ sprite.scale = 1 .0f ;
314+ sprite.positionType = CCPositionTypeNormalized;
315+ sprite.position = ccp (0 .5f , 0 .5f );
316+ sprite.effect = effect;
317+
318+ [self .contentNode addChild: sprite];
319+
320+ const float thetaStep = CC_DEGREES_TO_RADIANS (10 .0f );
321+ __block float redTheta = CC_DEGREES_TO_RADIANS (0 .0f );
322+ __block float greenTheta = CC_DEGREES_TO_RADIANS (120 .0f );
323+ __block float blueTheta = CC_DEGREES_TO_RADIANS (240 .0f );
324+ void (^updateBlock)() = ^{
325+
326+ float redRadius = 3 .0f ;
327+ effect.redOffset = GLKVector2Make (redRadius * cosf (redTheta), redRadius * sinf (redTheta));
328+
329+ float greenRadius = 3 .0f ;
330+ effect.greenOffset = GLKVector2Make (greenRadius * cosf (greenTheta), greenRadius * sinf (greenTheta));
331+
332+ float blueRadius = 3 .0f ;
333+ effect.blueOffset = GLKVector2Make (blueRadius * cosf (blueTheta), blueRadius * sinf (blueTheta));
334+
335+ redTheta += thetaStep;
336+ greenTheta += thetaStep;
337+ blueTheta += thetaStep;
338+ };
339+ updateBlock ();
340+
341+ [sprite runAction: [CCActionRepeatForever actionWithAction: [CCActionSequence actions:
342+ [CCActionDelay actionWithDuration: 0 .1f ],
343+ [CCActionCallBlock actionWithBlock: updateBlock],
344+ nil
345+ ]]];
346+ }
347+
203348#pragma mark DropShadow
204349
205350-(void )setupDropShadowEffectTest
@@ -608,13 +753,14 @@ -(void)setupBloomEffectTest
608753 const int steps = 5 ;
609754 for (int i = 0 ; i < steps; i++)
610755 {
611- CCSprite *sampleSprite3 = [CCSprite spriteWithImageNamed: @" Images/grossini_dance_08 .png" ];
756+ CCSprite *sampleSprite3 = [CCSprite spriteWithImageNamed: @" Images/f1 .png" ];
612757 sampleSprite3.anchorPoint = ccp (0.5 , 0.5 );
613758 sampleSprite3.position = ccp (0 .1f + i * (0 .8f / (steps - 1 )), 0 .2f );
614759 sampleSprite3.positionType = CCPositionTypeNormalized;
615760
616761 // Blend glow maps test
617- CCEffectBloom* glowEffect3 = [CCEffectBloom effectWithBlurRadius: 3 intensity: 1 .0f luminanceThreshold: 1 .0f - ((float )i/(float )(steps-1 ))];
762+ CCEffectBloom* glowEffect3 = [CCEffectBloom effectWithBlurRadius: 8 intensity: 1 .0f luminanceThreshold: 1 .0f - ((float )i/(float )(steps-1 ))];
763+ glowEffect3.padding = CGSizeMake (10 .0f , 10 .0f );
618764 sampleSprite3.effect = glowEffect3;
619765
620766 [self .contentNode addChild: sampleSprite3];
0 commit comments