Skip to content

Commit bee6034

Browse files
Support for cleanUp in CCActionRemove without breaking backwards compatibility.
1 parent 527f906 commit bee6034

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

cocos2d/CCActionInstant.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,12 @@
5252
5353
id action = [CCActionRemove action];
5454
*/
55-
@interface CCActionRemove : CCActionInstant
55+
@interface CCActionRemove : CCActionInstant {
56+
BOOL _cleanUp;
57+
}
58+
59+
+(id)action;
60+
+(id)actionWithCleanUp:(BOOL)cleanup;
5661

5762
@end
5863

cocos2d/CCActionInstant.m

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,35 @@ -(CCActionFiniteTime*) reverse
8181

8282
@implementation CCActionRemove
8383

84+
+(id)action {
85+
return [[self alloc] init];
86+
}
87+
88+
+(id)actionWithCleanUp:(BOOL)cleanup {
89+
return [[self alloc] initWithCleanUp:cleanup];
90+
}
91+
92+
-(id)init {
93+
self = [super init];
94+
if (!self) return nil;
95+
96+
_cleanUp = true;
97+
98+
return self;
99+
}
100+
101+
-(id)initWithCleanUp:(BOOL)cleanUp {
102+
self = [super init];
103+
if (!self) return nil;
104+
105+
_cleanUp = cleanUp;
106+
107+
return self;
108+
}
109+
110+
84111
-(void) update:(CCTime)time {
85-
[(CCNode *)_target removeFromParent];
112+
[(CCNode *)_target removeFromParentAndCleanup:_cleanUp];
86113
}
87114
@end
88115

0 commit comments

Comments
 (0)