1

I use below code to run the animation, but how to reversed the animation? (For example, a door model has an open animation, but I want to make it close)

CC3ResourceNode* rezNode = [CC3PODResourceNode nodeFromFile: @"bd1hW1368.POD"];
    [self addChild: rezNode];

    CCActionInterval *stride = [CC3Animate actionWithDuration:10.0];
    [rezNode runAction:[CCRepeatForever actionWithAction:stride]];

[UPDATE]

Related to Bill's answer, I create a continuous door close/open animation as below:

    CC3ResourceNode* rezNode = [CC3PODResourceNode nodeFromFile: @"bd1hW1368.POD"];
    [self addChild: rezNode];

    CC3Animate *stride = [CC3Animate actionWithDuration:10.0];
    CC3Animate *reversedStride = [CC3Animate actionWithDuration:10.0];
    reversedStride.isReversed = YES;

    CCRepeatForever *repeat = [CCRepeatForever actionWithAction:[CCSequence actionWithArray:@[stride, reversedStride]]];
    [rezNode runAction:repeat];
ZYiOS
  • 5,204
  • 3
  • 39
  • 45

1 Answers1

1

Like most CCActionInterval subclasses, CC3Animate supports the reverse method, which returns a new CC3Animate instance configured to run backwards.

You can also reuse the same CC3Animate instance and set the isReversed property to YES, but creating a separate instance using the reverse method will allow you to more easily do things like sequence a door open action followed by a door close action.

Bill Hollings
  • 2,344
  • 17
  • 25