Reputation: 5280
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];
Upvotes: 1
Views: 106
Reputation: 2374
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.
Upvotes: 1