Skip to content

Commit 5c91c8f

Browse files
committed
Merge commit '516ef6d' into develop
Conflicts: .gitmodules external/ObjectAL
2 parents 7094bab + 516ef6d commit 5c91c8f

File tree

7 files changed

+335
-9
lines changed

7 files changed

+335
-9
lines changed

cocos2d-ios.xcodeproj/project.pbxproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,10 @@
282282
D28A2E1D1954F7E000ADC03D /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D28A2E1C1954F7E000ADC03D /* OpenGLES.framework */; };
283283
D28A2E211954F85700ADC03D /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D28A2E201954F85700ADC03D /* AVFoundation.framework */; };
284284
D291DCC2195B2FA100278EC0 /* libObjectiveChipmunk-iPhone.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B759E52D1880C66900E8166C /* libObjectiveChipmunk-iPhone.a */; };
285+
D299CE7A19C2910B00519CBB /* CCEffectDFInnerGlow.h in Headers */ = {isa = PBXBuildFile; fileRef = D299CE7819C2910B00519CBB /* CCEffectDFInnerGlow.h */; };
286+
D299CE7B19C2910B00519CBB /* CCEffectDFInnerGlow.h in Headers */ = {isa = PBXBuildFile; fileRef = D299CE7819C2910B00519CBB /* CCEffectDFInnerGlow.h */; };
287+
D299CE7C19C2910B00519CBB /* CCEffectDFInnerGlow.m in Sources */ = {isa = PBXBuildFile; fileRef = D299CE7919C2910B00519CBB /* CCEffectDFInnerGlow.m */; };
288+
D299CE7D19C2910B00519CBB /* CCEffectDFInnerGlow.m in Sources */ = {isa = PBXBuildFile; fileRef = D299CE7919C2910B00519CBB /* CCEffectDFInnerGlow.m */; };
285289
D2DDB09319805E8400233D80 /* CCMathUtilsAndroid.h in Headers */ = {isa = PBXBuildFile; fileRef = D2DDB08819805E8400233D80 /* CCMathUtilsAndroid.h */; };
286290
D2DDB09419805E8400233D80 /* CCMathUtilsAndroid.h in Headers */ = {isa = PBXBuildFile; fileRef = D2DDB08819805E8400233D80 /* CCMathUtilsAndroid.h */; };
287291
D2DDB09519805E8400233D80 /* CCMatrix3.h in Headers */ = {isa = PBXBuildFile; fileRef = D2DDB08919805E8400233D80 /* CCMatrix3.h */; };
@@ -915,6 +919,8 @@
915919
D28A2E1A1954F68D00ADC03D /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
916920
D28A2E1C1954F7E000ADC03D /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; };
917921
D28A2E201954F85700ADC03D /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; };
922+
D299CE7819C2910B00519CBB /* CCEffectDFInnerGlow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEffectDFInnerGlow.h; sourceTree = "<group>"; };
923+
D299CE7919C2910B00519CBB /* CCEffectDFInnerGlow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCEffectDFInnerGlow.m; sourceTree = "<group>"; };
918924
D2B840C31909F447008063EA /* CCRenderTexture_Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCRenderTexture_Private.h; sourceTree = "<group>"; };
919925
D2DDB08819805E8400233D80 /* CCMathUtilsAndroid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCMathUtilsAndroid.h; path = Platforms/Android/CCMathUtilsAndroid.h; sourceTree = "<group>"; };
920926
D2DDB08919805E8400233D80 /* CCMatrix3.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCMatrix3.h; path = Platforms/Android/CCMatrix3.h; sourceTree = "<group>"; };
@@ -1584,6 +1590,8 @@
15841590
D27451B619AE5517006DA0A1 /* CCEffectDistanceField.m */,
15851591
D27451C419B111A9006DA0A1 /* CCEffectDFOutline.h */,
15861592
D27451C519B111A9006DA0A1 /* CCEffectDFOutline.m */,
1593+
D299CE7819C2910B00519CBB /* CCEffectDFInnerGlow.h */,
1594+
D299CE7919C2910B00519CBB /* CCEffectDFInnerGlow.m */,
15871595
);
15881596
name = DistanceField;
15891597
sourceTree = "<group>";
@@ -1742,6 +1750,7 @@
17421750
50F7B2780F28DE7C00057537 /* CCActionEase.h in Headers */,
17431751
571CD02819649E03003D460C /* CCPlatformTextField.h in Headers */,
17441752
B798D1451820305400E7BFCD /* CCSprite_Private.h in Headers */,
1753+
D299CE7A19C2910B00519CBB /* CCEffectDFInnerGlow.h in Headers */,
17451754
50BAF3990F33CCD8003F654C /* ccMacros.h in Headers */,
17461755
B798D13D181F2E4500E7BFCD /* CCNode_Private.h in Headers */,
17471756
509A79970F6188420032F449 /* CCSprite.h in Headers */,
@@ -1982,6 +1991,7 @@
19821991
D2FEB693194F6C9E00FC0574 /* CCProgressNode.h in Headers */,
19831992
D2DDB09419805E8400233D80 /* CCMathUtilsAndroid.h in Headers */,
19841993
D2FEB694194F6C9E00FC0574 /* CCLayout.h in Headers */,
1994+
D299CE7B19C2910B00519CBB /* CCEffectDFInnerGlow.h in Headers */,
19851995
D2FEB695194F6C9E00FC0574 /* NSThread+performBlock.h in Headers */,
19861996
D2FEB696194F6C9E00FC0574 /* CCTiledMapLayer_Private.h in Headers */,
19871997
D2FEB69A194F6C9E00FC0574 /* CCTransition.h in Headers */,
@@ -2177,6 +2187,7 @@
21772187
files = (
21782188
5018F26A0DFDEAFF00C013A5 /* CCAction.m in Sources */,
21792189
D3903B0B1995285B003AA81A /* CCEffectBlur.m in Sources */,
2190+
D299CE7C19C2910B00519CBB /* CCEffectDFInnerGlow.m in Sources */,
21802191
5018F26C0DFDEAFF00C013A5 /* CCNode.m in Sources */,
21812192
5018F26E0DFDEAFF00C013A5 /* CCDirector.m in Sources */,
21822193
5018F2700DFDEAFF00C013A5 /* CCActionInstant.m in Sources */,
@@ -2317,6 +2328,7 @@
23172328
files = (
23182329
57202D391970776100238D56 /* CCPlatformTextFieldAndroid.m in Sources */,
23192330
D2FEB6B9194F6C9E00FC0574 /* CCAction.m in Sources */,
2331+
D299CE7D19C2910B00519CBB /* CCEffectDFInnerGlow.m in Sources */,
23202332
D2FEB6BA194F6C9E00FC0574 /* CCNode.m in Sources */,
23212333
D2FEB6BB194F6C9E00FC0574 /* CCDirector.m in Sources */,
23222334
D2FEB6BC194F6C9E00FC0574 /* CCActionInstant.m in Sources */,

cocos2d-ui-tests/tests/CCEffectsTest.m

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ @implementation CCEffectsTest {
1212
#if CC_EFFECTS_EXPERIMENTAL
1313
CCEffectDistanceField* _distanceFieldEffect;
1414
CCEffectDFOutline* _outlineEffect;
15+
CCEffectDFInnerGlow* _innerGlowEffect;
1516
#endif
1617
}
1718

@@ -29,6 +30,56 @@ -(id)init
2930

3031
#if CC_EFFECTS_EXPERIMENTAL
3132

33+
-(void)setupDFInnerGlowTest
34+
{
35+
self.subTitle = @"Distance Field Inner Glow Test";
36+
37+
CCSprite *environment = [CCSprite spriteWithImageNamed:@"Images/MountainPanorama.jpg"];
38+
environment.positionType = CCPositionTypeNormalized;
39+
environment.anchorPoint = ccp(0.5, 0.5);
40+
environment.position = ccp(0.5f, 0.5f);
41+
42+
CCTexture* texture = [[CCTextureCache sharedTextureCache] addImage:@"Images/output.png"];
43+
44+
CCColor* fillColor = [CCColor colorWithRed:0.0 green:1.0 blue:0.0 alpha:0.5];
45+
_innerGlowEffect = [CCEffectDFInnerGlow effectWithGlowColor:[CCColor redColor] fillColor:fillColor glowWidth:2 fieldScale:32 distanceField:texture];
46+
47+
CCSprite *dfSprite = [CCSprite spriteWithImageNamed:@"Images/df_sprite.png"];
48+
dfSprite.position = ccp(0.5, 0.5);
49+
dfSprite.positionType = CCPositionTypeNormalized;
50+
dfSprite.effect = _innerGlowEffect;
51+
dfSprite.scale = 1.0f;
52+
53+
CCSpriteFrame* background = [CCSpriteFrame frameWithImageNamed:@"Tests/slider-background.png"];
54+
CCSpriteFrame* backgroundHilite = [CCSpriteFrame frameWithImageNamed:@"Tests/slider-background-hilite.png"];
55+
CCSpriteFrame* handle = [CCSpriteFrame frameWithImageNamed:@"Tests/slider-handle.png"];
56+
57+
CCSlider* slider = [[CCSlider alloc] initWithBackground:background andHandleImage:handle];
58+
[slider setBackgroundSpriteFrame:backgroundHilite forState:CCControlStateHighlighted];
59+
slider.positionType = CCPositionTypeNormalized;
60+
slider.position = ccp(0.1f, 0.5f);
61+
slider.sliderValue = 0.3;
62+
slider.preferredSizeType = CCSizeTypeMake(CCSizeUnitNormalized, CCSizeUnitUIPoints);
63+
slider.preferredSize = CGSizeMake(0.5f, 10);
64+
slider.rotation = 90;
65+
slider.anchorPoint = ccp(0.5f, 0.5f);
66+
slider.scale = 0.8;
67+
68+
[slider setTarget:self selector:@selector(innerGlowWidthChanged:)];
69+
70+
[self.contentNode addChild:environment];
71+
[self.contentNode addChild:slider];
72+
[self.contentNode addChild:dfSprite];
73+
}
74+
75+
- (void)innerGlowWidthChanged:(id)sender
76+
{
77+
const int innerGloWMax = 6;
78+
CCSlider* slider = sender;
79+
_innerGlowEffect.glowWidth = slider.sliderValue * innerGloWMax;
80+
}
81+
82+
3283
-(void)setupDFOutlineEffectTest
3384
{
3485
self.subTitle = @"Distance Field Outline Test";
@@ -40,8 +91,8 @@ -(void)setupDFOutlineEffectTest
4091

4192
CCTexture* texture = [[CCTextureCache sharedTextureCache] addImage:@"Images/output.png"];
4293

43-
CCColor* fillColor = [CCColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.0];
44-
_outlineEffect = [CCEffectDFOutline effectWithOutlineColor:[CCColor redColor] fillColor:fillColor outlineWidth:3 fieldScale:32 distanceField:texture];
94+
CCColor* fillColor = [CCColor colorWithRed:0.0 green:0.0 blue:1.0 alpha:0.0];
95+
_outlineEffect = [CCEffectDFOutline effectWithOutlineColor:[CCColor redColor] fillColor:fillColor outlineWidth:1 fieldScale:32 distanceField:texture];
4596

4697
CCSprite *dfSprite = [CCSprite spriteWithImageNamed:@"Images/df_sprite.png"];
4798
dfSprite.position = ccp(0.5, 0.5);
@@ -57,12 +108,12 @@ -(void)setupDFOutlineEffectTest
57108
[slider setBackgroundSpriteFrame:backgroundHilite forState:CCControlStateHighlighted];
58109
slider.positionType = CCPositionTypeNormalized;
59110
slider.position = ccp(0.1f, 0.5f);
60-
61111
slider.preferredSizeType = CCSizeTypeMake(CCSizeUnitNormalized, CCSizeUnitUIPoints);
62112
slider.preferredSize = CGSizeMake(0.5f, 10);
63113
slider.rotation = 90;
64114
slider.anchorPoint = ccp(0.5f, 0.5f);
65115
slider.scale = 0.8;
116+
slider.sliderValue = 0.1;
66117

67118
[slider setTarget:self selector:@selector(outlineWidthChagne:)];
68119

cocos2d/CCEffectDFInnerGlow.h

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
//
2+
// CCEffectDFInnerGlow.h
3+
// cocos2d-ios
4+
//
5+
// Created by Oleg Osin on 9/11/14.
6+
//
7+
//
8+
9+
#import "CCEffect.h"
10+
11+
/**
12+
* CCEffectDFInnerGlow create an inner glow on any sprite (combined with a distance field).
13+
*
14+
*/
15+
#if CC_EFFECTS_EXPERIMENTAL
16+
17+
@interface CCEffectDFInnerGlow : CCEffect
18+
19+
/// -----------------------------------------------------------------------
20+
/// @name Accessing Effect Attributes
21+
/// -----------------------------------------------------------------------
22+
23+
/** Color of the sprite (pass a fillColor with with alpha value of 0.0 to see the actual sprite) */
24+
@property (nonatomic, strong) CCColor* fillColor;
25+
26+
/** Color of glow */
27+
@property (nonatomic, strong) CCColor* glowColor;
28+
29+
/** Outline width pixel width of the glow */
30+
@property (nonatomic) int glowWidth;
31+
32+
// Distance Field, generated by SDFGen (https://github.com/osinoleg/SDFGen)
33+
@property (nonatomic, strong) CCTexture* distanceField;
34+
35+
/// -----------------------------------------------------------------------
36+
/// @name Initializing a CCEffectDFInnerGlow object
37+
/// -----------------------------------------------------------------------
38+
39+
/**
40+
* Initializes a CCEffectDFInnerGlow.
41+
*
42+
* @return The CCEffectDFInnerGlow object.
43+
*/
44+
-(id)init;
45+
46+
/**
47+
* Initializes a CCEffectDFInnerGlow object with the supplied parameters.
48+
*
49+
* @param glowColor Color of the glow, a [CCColor blackColor] will result in an opaque black glow.
50+
* @param fillColor Color of the fillColor, a [CCColor blackColor] will result in an opaque black fillColor.
51+
* @param glowWidth pixel width of the glow.
52+
* @param fieldScale, defined by the distance field generation proccess, for example a distance field that
53+
* was generated with a 4096/4096 input and output a 128/128 texture would have a fieldScale of 32 (
54+
* input size / output size). Note: this parameter could be automatically calculated if we assume that all
55+
* distance fields are generated from a 4096 input.
56+
*
57+
* @return The CCEffectDFInnerGlow object.
58+
*/
59+
-(id)initWithGlowColor:(CCColor*)glowColor fillColor:(CCColor*)fillColor glowWidth:(int)glowWidth fieldScale:(float)fieldScale distanceField:(CCTexture*)distanceField;
60+
61+
62+
/// -----------------------------------------------------------------------
63+
/// @name Creating a CCEffectDFInnerGlow object
64+
/// -----------------------------------------------------------------------
65+
66+
/**
67+
* Initializes a CCEffectDFInnerGlow object with the supplied parameters.
68+
*
69+
* @param glowColor Color of the glow, a [CCColor blackColor] will result in an opaque black glow.
70+
* @param fillColor Color of the fillColor, a [CCColor blackColor] will result in an opaque black fillColor.
71+
* @param glowWidth pixel width of the glow.
72+
* @param fieldScale, defined by the distance field generation proccess, for example a distance field that
73+
* was generated with a 4096/4096 input and output a 128/128 texture would have a fieldScale of 32 (
74+
* input size / output size). Note: this parameter could be automatically calculated if we assume that all
75+
* distance fields are generated from a 4096 input.
76+
*
77+
* @return The CCEffectDFInnerGlow object.
78+
*/
79+
+(id)effectWithGlowColor:(CCColor*)glowColor fillColor:(CCColor*)fillColor glowWidth:(int)glowWidth fieldScale:(float)fieldScale distanceField:(CCTexture*)distanceField;
80+
81+
@end
82+
83+
#endif
84+

0 commit comments

Comments
 (0)