Skip to content

Commit 55f77c3

Browse files
author
Thayer J Andrews
committed
CCEffectStack - Add a constructor method.
1 parent 31945f6 commit 55f77c3

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

cocos2d-ui-tests/tests/CCEffectsTest.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -527,8 +527,8 @@ -(void)setupStackTest
527527
sprite.position = ccp(0.5f, 0.5f);
528528
sprite.scale = 0.5f;
529529

530-
sprite.effect = [[CCEffectStack alloc] initWithEffects:@[effects[8], effects[9]]];
531-
// sprite.effect = [[CCEffectStack alloc] initWithEffects:@[effects[7]]];
530+
sprite.effect = [CCEffectStack effectStackWithEffects:@[effects[8], effects[9]]];
531+
// sprite.effect = [CCEffectStack effectStackWithEffects:@[effects[7]]];
532532

533533
sprite.normalMapSpriteFrame = [CCSpriteFrame frameWithImageNamed:@"Images/ShinyBallNormals.png"];
534534
sprite.colorRGBA = [CCColor colorWithRed:0.75f green:0.75f blue:0.75f alpha:0.75f];
@@ -662,7 +662,7 @@ - (CCNode *)effectNodeWithEffects:(NSArray *)effects appliedToSpriteWithImage:(N
662662
}
663663
else if (effects.count > 1)
664664
{
665-
CCEffectStack *stack = [[CCEffectStack alloc] initWithEffects:effects];
665+
CCEffectStack *stack = [CCEffectStack effectStackWithEffects:effects];
666666
effectNode.effect = stack;
667667
}
668668

@@ -683,7 +683,7 @@ - (CCSprite *)spriteWithEffects:(NSArray *)effects image:(NSString *)spriteImage
683683
}
684684
else if (effects.count > 1)
685685
{
686-
CCEffectStack *stack = [[CCEffectStack alloc] initWithEffects:effects];
686+
CCEffectStack *stack = [CCEffectStack effectStackWithEffects:effects];
687687
sprite.effect = stack;
688688
}
689689

cocos2d/CCEffectStack.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
- (id)init;
3939

4040
/**
41-
* Initializes an empty effect stack object.
41+
* Initializes an effect stack object with the specified array of effects.
4242
*
4343
* @param effects The array of effects to add to the stack.
4444
*
@@ -47,6 +47,20 @@
4747
- (id)initWithEffects:(NSArray *)effects;
4848

4949

50+
/// -----------------------------------------------------------------------
51+
/// @name Creating a CCEffectStack object
52+
/// -----------------------------------------------------------------------
53+
54+
/**
55+
* Creates an effect stack object with the specified array of effects.
56+
*
57+
* @param effects The array of effects to add to the stack.
58+
*
59+
* @return The CCEffectStack object.
60+
*/
61+
+ (id)effectStackWithEffects:(NSArray *)effects;
62+
63+
5064
/// -----------------------------------------------------------------------
5165
/// @name Accessing Contained Effects
5266
/// -----------------------------------------------------------------------

cocos2d/CCEffectStack.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ - (id)initWithEffects:(NSArray *)effects
4646
return self;
4747
}
4848

49+
+ (id)effectStackWithEffects:(NSArray *)effects
50+
{
51+
return [[self alloc] initWithEffects:effects];
52+
}
53+
4954
- (NSUInteger)effectCount
5055
{
5156
return _effects.count;

0 commit comments

Comments
 (0)