TargetedAction::reverse implementation


#1

Shouldn’t the reverse on Targeted Action just call reverse on the action instead of clone?

Current implementation is like

TargetedAction* TargetedAction::reverse(void) const
{
    // no reverse for this action, just clone it
    return this->clone();
}

How about the following.

TargetedAction* TargetedAction::reverse() const
{
    auto a = new TargetedAction();
    a->initWithTarget(_forcedTarget, _action->reverse());
    a->autorelease();
    return a;
}

Not having proper reverse method on TargetedActions make it difficult to use in complex runAction sequences. Simple example in JSB

var rotate = cc.Sequence.create(
    cc.TargetedAction.create(spriteA, cc.RotateBy.create(2, 180)),
    cc.TargetedAction.create(spriteB, cc.RotateBy.create(2, 180))
);

var action = cc.Sequence.create(rotate, rotate.reverse());
someLayer.runAction(action);

#2

Anyone?


#3

@Shuja Shabandri
I think you are right, #2423 is created for it.

Thanks.