views:

229

answers:

1

Hi, I am doing my program in cocos2d. I am using NSDate to get the current time of the start of animation. And I know my animation takes 3 seconds. So I can get the time at completion of animation by using NSInterval and using the previous time and animation time. But, if If the animation time interval is not fixed how can I calculate the time interval of the animation and time at the completion of the animation ? I am animating a sprite. Please help how can I make it. Thank You.

+1  A: 

The CCIntervalAction class has a property called elapsed that gives you the number of seconds that have elapsed since the action started as a ccTime. Since the CCAnimate action derives from CCIntervalAction, you should have access to this property.

CCAnimation *myAnimation = [CCAnimation animationWithName:@"my animation" delay:0.1f];
CCAnimate *myAnimateAction = [CCAnimate actionWithAnimation:myAnimation];
[sprite runAction:myAnimateAction];
...
ccTime interval = myAnimateAction.elapsed;
derekvanvliet