开发者

how can we count the time interval of the animation in cocos2d?

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. Bu开发者_高级运维t, 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.


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;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜