Cocos2d iphone 我的CCTargetedAction运行了两次操作

Cocos2d iphone 我的CCTargetedAction运行了两次操作,cocos2d-iphone,ccaction,Cocos2d Iphone,Ccaction,在cocos2dv3中,我找不到类似CCTargetedAction的东西。 在我的项目中它是必需的,所以我从cocos2dv2复制了代码 @interface CCTargetedAction : CCActionInterval /** This is the target that the action will be forced to run with */ @property(readwrite,nonatomic,retain) id forcedTarget; @propert

在cocos2dv3中,我找不到类似CCTargetedAction的东西。 在我的项目中它是必需的,所以我从cocos2dv2复制了代码

@interface CCTargetedAction : CCActionInterval

/** This is the target that the action will be forced to run with */
@property(readwrite,nonatomic,retain) id forcedTarget;
@property(readwrite,nonatomic,retain) CCActionFiniteTime* action;

/** Create an action with the specified action and forced target */
+(id)actionWithTarget:(id)target
               action:(CCActionFiniteTime*)action;

/** Init an action with the specified action and forced target */
-(id)initWithTarget:(id)target
             action:(CCActionFiniteTime*)action;
@end
@implementation CCTargetedAction

+(id)actionWithTarget:(id)target
               action:(CCActionFiniteTime*)action
{
    return [(CCTargetedAction*)[self alloc] initWithTarget:target
                                                    action:action];
}
-(id)initWithTarget:(id)target
             action:(CCActionFiniteTime*)action
{
    self = [super initWithDuration:action.duration];
    if(self)
    {
        self.forcedTarget = target;
        self.action = action;
    }
    return self;
}

-(id)copyWithZone:(NSZone*)zone
{
    CCAction *copy = [(CCTargetedAction*) [[self class] allocWithZone: zone]
                      initWithTarget:_forcedTarget
                      action:[_action copy]];
    return copy;
}

- (void) startWithTarget:(id)aTarget
{
    [super startWithTarget:aTarget];
    [_action startWithTarget:_forcedTarget];
}

- (void) stop
{
    [_action stop];
}

- (void) update:(CCTime) time
{
    [_action update:time];
}
@end
但我的CCTargetedAction运行了两次

-(void) touchBegan:(UITouch *)touch withEvent:(UIEvent *)event {
    CCActionCallBlock* block = [CCActionCallBlock actionWithBlock:^{
        CCLOG(@"call block");
    }];
    CCTargetedAction* action = [CCTargetedAction actionWithTarget:self
                                                           action:block];
    [self runAction:action];
}
如果我触摸屏幕一次,则日志消息输出两次

2014-04-07 22:09:57.439 TargetedActionTest[3924:60b] call block
2014-04-07 22:09:57.455 TargetedActionTest[3924:60b] call block
为什么此代码会运行两次操作


谢谢。

此问题通过覆盖-(BOOL)isDone方法解决

-(BOOL)isDone
{
    return [_action isDone];
}
我指的是这篇文章。