Skip to content

Commit 552dcd5

Browse files
committed
Merge branch 'develop' of git://github.com/thayerandrews/cocos2d-iphone into 963
Conflicts: cocos2d-ios.xcodeproj/project.pbxproj cocos2d-osx.xcodeproj/project.pbxproj cocos2d-ui-tests/tests/CCEffectsTest.m cocos2d/CCEffectBlur.m external/ObjectAL
2 parents 529ac53 + f6dbb41 commit 552dcd5

20 files changed

+795
-171
lines changed

cocos2d-ios.xcodeproj/project.pbxproj

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@
118118
9D85671E191B018200573093 /* CCEffectBrightness.m in Sources */ = {isa = PBXBuildFile; fileRef = 9D85671C191B018200573093 /* CCEffectBrightness.m */; };
119119
9D856721191B019900573093 /* CCEffectContrast.h in Headers */ = {isa = PBXBuildFile; fileRef = 9D85671F191B019900573093 /* CCEffectContrast.h */; };
120120
9D856722191B019900573093 /* CCEffectContrast.m in Sources */ = {isa = PBXBuildFile; fileRef = 9D856720191B019900573093 /* CCEffectContrast.m */; };
121+
9DBCA31419B68BE400EFE96D /* CCEffectColorChannelOffset.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DBCA31219B68BE400EFE96D /* CCEffectColorChannelOffset.h */; };
122+
9DBCA31519B68BE400EFE96D /* CCEffectColorChannelOffset.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DBCA31319B68BE400EFE96D /* CCEffectColorChannelOffset.m */; };
121123
9DF37621191C594A00C6D27A /* CCEffectPixellate.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DF3761F191C594A00C6D27A /* CCEffectPixellate.h */; };
122124
9DF37622191C594A00C6D27A /* CCEffectPixellate.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DF37620191C594A00C6D27A /* CCEffectPixellate.m */; };
123125
A003AC8C1657071100C7B792 /* ccFPSImages.h in Headers */ = {isa = PBXBuildFile; fileRef = A003AC8B1657071100C7B792 /* ccFPSImages.h */; };
@@ -761,7 +763,7 @@
761763
5BC3CB5219626E4F00C4F0D0 /* CCGestureListener.java */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.java; path = CCGestureListener.java; sourceTree = "<group>"; };
762764
5BC3CB5719626FA000C4F0D0 /* CCGestureListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCGestureListener.h; path = Android/CCGestureListener.h; sourceTree = "<group>"; };
763765
5BC3CB5819626FA000C4F0D0 /* CCGestureListener.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CCGestureListener.m; path = Android/CCGestureListener.m; sourceTree = "<group>"; };
764-
5BF3267A195F8D8800D9A51A /* cocos2dJava.jar */ = {isa = PBXFileReference; explicitFileType = compiled.java.jar; includeInIndex = 0; path = cocos2dJava.jar; sourceTree = BUILT_PRODUCTS_DIR; };
766+
5BF3267A195F8D8800D9A51A /* cocos2dJava.jar */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = archive.jar; path = cocos2dJava.jar; sourceTree = BUILT_PRODUCTS_DIR; };
765767
5BF3268C195F8E0300D9A51A /* CCActivity.java */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.java; path = CCActivity.java; sourceTree = "<group>"; };
766768
5BF3268D195F8E0300D9A51A /* CCGLView.java */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.java; path = CCGLView.java; sourceTree = "<group>"; };
767769
5BF32696195F947800D9A51A /* CCActivity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCActivity.h; path = Android/CCActivity.h; sourceTree = "<group>"; };
@@ -772,6 +774,8 @@
772774
9D85671C191B018200573093 /* CCEffectBrightness.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCEffectBrightness.m; sourceTree = "<group>"; };
773775
9D85671F191B019900573093 /* CCEffectContrast.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEffectContrast.h; sourceTree = "<group>"; };
774776
9D856720191B019900573093 /* CCEffectContrast.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCEffectContrast.m; sourceTree = "<group>"; };
777+
9DBCA31219B68BE400EFE96D /* CCEffectColorChannelOffset.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEffectColorChannelOffset.h; sourceTree = "<group>"; };
778+
9DBCA31319B68BE400EFE96D /* CCEffectColorChannelOffset.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCEffectColorChannelOffset.m; sourceTree = "<group>"; };
775779
9DF3761F191C594A00C6D27A /* CCEffectPixellate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEffectPixellate.h; sourceTree = "<group>"; };
776780
9DF37620191C594A00C6D27A /* CCEffectPixellate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCEffectPixellate.m; sourceTree = "<group>"; };
777781
A003AC8B1657071100C7B792 /* ccFPSImages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccFPSImages.h; sourceTree = "<group>"; };
@@ -1534,6 +1538,8 @@
15341538
isa = PBXGroup;
15351539
children = (
15361540
D27451BF19AFC44D006DA0A1 /* DistanceField */,
1541+
9DBCA31219B68BE400EFE96D /* CCEffectColorChannelOffset.h */,
1542+
9DBCA31319B68BE400EFE96D /* CCEffectColorChannelOffset.m */,
15371543
D3903B081995285B003AA81A /* CCEffectBlur.h */,
15381544
D3903B091995285B003AA81A /* CCEffectBlur.m */,
15391545
D268FE151980791300ECBCD0 /* CCEffectRefraction.h */,
@@ -1710,6 +1716,7 @@
17101716
B7D273111822F4AA0054849B /* CCBLocalizationManager.h in Headers */,
17111717
5018F2690DFDEAFF00C013A5 /* CCAction.h in Headers */,
17121718
5018F26B0DFDEAFF00C013A5 /* CCNode.h in Headers */,
1719+
9DBCA31419B68BE400EFE96D /* CCEffectColorChannelOffset.h in Headers */,
17131720
5018F26D0DFDEAFF00C013A5 /* CCDirector.h in Headers */,
17141721
5018F26F0DFDEAFF00C013A5 /* CCActionInstant.h in Headers */,
17151722
5018F2710DFDEAFF00C013A5 /* CCActionInterval.h in Headers */,
@@ -2214,6 +2221,7 @@
22142221
50CB3B0F100AC43A00B7A750 /* CCActionManager.m in Sources */,
22152222
D3903B11199528A0003AA81A /* CCRenderDispatch.m in Sources */,
22162223
B7E775D118527EF0004221AA /* CCAppDelegate.m in Sources */,
2224+
9DBCA31519B68BE400EFE96D /* CCEffectColorChannelOffset.m in Sources */,
22172225
D3903B15199528B6003AA81A /* CCMetalView.m in Sources */,
22182226
B7D273141822F4AA0054849B /* CCBReader.m in Sources */,
22192227
50F29F5610204FD60046CA73 /* base64.c in Sources */,

cocos2d-osx.xcodeproj/project.pbxproj

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
926B97E519385F8A00E345FB /* CCAnimationManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 926B97E019385F8A00E345FB /* CCAnimationManager.h */; };
1919
926B97EA1938602200E345FB /* CCAnimationManager+FrameAnimation.m in Sources */ = {isa = PBXBuildFile; fileRef = 926B97E81938602200E345FB /* CCAnimationManager+FrameAnimation.m */; };
2020
926B97EB1938602200E345FB /* CCAnimationManager+FrameAnimation.h in Headers */ = {isa = PBXBuildFile; fileRef = 926B97E91938602200E345FB /* CCAnimationManager+FrameAnimation.h */; };
21+
9D9E341519B7AAB800ADD7CB /* CCEffectColorChannelOffset.h in Headers */ = {isa = PBXBuildFile; fileRef = 9D9E340F19B7AAB800ADD7CB /* CCEffectColorChannelOffset.h */; };
22+
9D9E341619B7AAB800ADD7CB /* CCEffectColorChannelOffset.m in Sources */ = {isa = PBXBuildFile; fileRef = 9D9E341019B7AAB800ADD7CB /* CCEffectColorChannelOffset.m */; };
23+
9D9E341719B7AAB800ADD7CB /* CCEffectDropShadow.h in Headers */ = {isa = PBXBuildFile; fileRef = 9D9E341119B7AAB800ADD7CB /* CCEffectDropShadow.h */; };
24+
9D9E341819B7AAB800ADD7CB /* CCEffectDropShadow.m in Sources */ = {isa = PBXBuildFile; fileRef = 9D9E341219B7AAB800ADD7CB /* CCEffectDropShadow.m */; };
25+
9D9E341919B7AAB800ADD7CB /* CCEffectOuterGlow.h in Headers */ = {isa = PBXBuildFile; fileRef = 9D9E341319B7AAB800ADD7CB /* CCEffectOuterGlow.h */; };
26+
9D9E341A19B7AAB800ADD7CB /* CCEffectOuterGlow.m in Sources */ = {isa = PBXBuildFile; fileRef = 9D9E341419B7AAB800ADD7CB /* CCEffectOuterGlow.m */; };
2127
A003ACA7165731D500C7B792 /* ccFPSImages.h in Headers */ = {isa = PBXBuildFile; fileRef = A003ACA5165731D500C7B792 /* ccFPSImages.h */; };
2228
A003ACA8165731D500C7B792 /* ccFPSImages.m in Sources */ = {isa = PBXBuildFile; fileRef = A003ACA6165731D500C7B792 /* ccFPSImages.m */; };
2329
A03714D7154F1D9300081CBA /* CCNode+Debug.h in Headers */ = {isa = PBXBuildFile; fileRef = A03714D5154F1D9300081CBA /* CCNode+Debug.h */; };
@@ -371,6 +377,12 @@
371377
926B97E019385F8A00E345FB /* CCAnimationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCAnimationManager.h; path = "cocos2d-ui/CCBReader/CCAnimationManager.h"; sourceTree = "<group>"; };
372378
926B97E81938602200E345FB /* CCAnimationManager+FrameAnimation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "CCAnimationManager+FrameAnimation.m"; path = "cocos2d-ui/CCBReader/CCAnimationManager+FrameAnimation.m"; sourceTree = "<group>"; };
373379
926B97E91938602200E345FB /* CCAnimationManager+FrameAnimation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "CCAnimationManager+FrameAnimation.h"; path = "cocos2d-ui/CCBReader/CCAnimationManager+FrameAnimation.h"; sourceTree = "<group>"; };
380+
9D9E340F19B7AAB800ADD7CB /* CCEffectColorChannelOffset.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEffectColorChannelOffset.h; sourceTree = "<group>"; };
381+
9D9E341019B7AAB800ADD7CB /* CCEffectColorChannelOffset.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCEffectColorChannelOffset.m; sourceTree = "<group>"; };
382+
9D9E341119B7AAB800ADD7CB /* CCEffectDropShadow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEffectDropShadow.h; sourceTree = "<group>"; };
383+
9D9E341219B7AAB800ADD7CB /* CCEffectDropShadow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCEffectDropShadow.m; sourceTree = "<group>"; };
384+
9D9E341319B7AAB800ADD7CB /* CCEffectOuterGlow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEffectOuterGlow.h; sourceTree = "<group>"; };
385+
9D9E341419B7AAB800ADD7CB /* CCEffectOuterGlow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCEffectOuterGlow.m; sourceTree = "<group>"; };
374386
A003ACA5165731D500C7B792 /* ccFPSImages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccFPSImages.h; sourceTree = "<group>"; };
375387
A003ACA6165731D500C7B792 /* ccFPSImages.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ccFPSImages.m; sourceTree = "<group>"; };
376388
A0191EAA167FDBA40099349A /* libc++.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = "libc++.dylib"; path = "usr/lib/libc++.dylib"; sourceTree = SDKROOT; };
@@ -935,6 +947,8 @@
935947
D3DBE16C19C8DED80009E45F /* CCEffectDistanceField.m */,
936948
D3DBE16F19C8DED80009E45F /* CCEffectDropShadow.h */,
937949
D3DBE17019C8DED80009E45F /* CCEffectDropShadow.m */,
950+
9D9E340F19B7AAB800ADD7CB /* CCEffectColorChannelOffset.h */,
951+
9D9E341019B7AAB800ADD7CB /* CCEffectColorChannelOffset.m */,
938952
D3903B01199527AA003AA81A /* CCEffectBlur.h */,
939953
D3903B02199527AA003AA81A /* CCEffectBlur.m */,
940954
D2D598421987132700BDAF25 /* CCEffect_Private.h */,
@@ -1489,6 +1503,7 @@
14891503
E076E75C1225EC7400DE0DA2 /* base64.h in Headers */,
14901504
B7D273311822F5460054849B /* CCBSequence.h in Headers */,
14911505
E076E7601225EC7400DE0DA2 /* CCFileUtils.h in Headers */,
1506+
9D9E341519B7AAB800ADD7CB /* CCEffectColorChannelOffset.h in Headers */,
14921507
E076E7621225EC7400DE0DA2 /* CCProfiling.h in Headers */,
14931508
E076E7651225EC7400DE0DA2 /* ccUtils.h in Headers */,
14941509
D2D598801987132700BDAF25 /* CCEffectStack_Private.h in Headers */,
@@ -1785,6 +1800,7 @@
17851800
A046E2B514C1E5000005BBF2 /* CCES2Renderer.m in Sources */,
17861801
A046E2B814C1E5000005BBF2 /* CCGLView.m in Sources */,
17871802
D389412918639DD400725CFC /* CCPhysicsJoint.m in Sources */,
1803+
9D9E341619B7AAB800ADD7CB /* CCEffectColorChannelOffset.m in Sources */,
17881804
A0C879AD14F98F1C00C0E8B2 /* NSThread+performBlock.m in Sources */,
17891805
571CD04119649E22003D460C /* CCPlatformTextFieldMac.m in Sources */,
17901806
D2D5986A1987132700BDAF25 /* CCEffectBrightness.m in Sources */,

cocos2d-ui-tests/tests/CCEffectsTest.m

Lines changed: 148 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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];

cocos2d/CCEffect.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,11 @@
2929
/** An identifier for debugging effects. */
3030
@property (nonatomic, copy) NSString *debugName;
3131

32+
/** Padding in points that will be applied to affected sprites to avoid clipping the
33+
* effect's visuals at the sprite's boundary. For example, if you create a blur effect
34+
* whose radius will animate over time but will never exceed 8 points then you should
35+
* set the padding to at least 8 to avoid clipping.
36+
*/
37+
@property (nonatomic, assign) CGSize padding;
38+
3239
@end

0 commit comments

Comments
 (0)