[英]How to set frame rate on CCAnimation
I have 5 sprite frames and i made them into an animation with a delay of 0.05 seconds between each frame. 我有5个Sprite帧,我将它们制作成动画,每帧之间有0.05秒的延迟。 I then used CCAnimate to turn it into an action then ran it on a sprite. 然后,我使用CCAnimate将其转换为动作,然后在精灵上运行它。
CCAnimation *animation = [CCAnimation animationWithFrames:animationArray delay:0.05];
CCAnimate *animate = [CCAnimate actionWithDuration:10.0 animation:animation restoreOriginalFrame:YES];
[sprite runAction:animate];
The issue is that the frames have a delay of 2 seconds rather than 0.05. 问题在于帧的延迟为2秒而不是0.05。 Is it possible to loop the animation with a frame ever 0.05 seconds for a duration of 10 seconds? 是否可以以0.05秒的帧循环播放动画,持续10秒?
I would suggest the following: 我建议以下内容:
make sure that the first argument to CCAnimate actionWithDuration
matches the product of your delay` by the number of frames you have; 确保CCAnimate actionWithDuration
的第一个参数与CCAnimate actionWithDuration
与您拥有的帧数相匹配;
use CCRepeat
to repeat in a loop your basic animation: 使用CCRepeat
循环播放基本动画:
CCRepeat* repeat = [CCRepeat actionWithAction:animate times:5]; [sprite runAction:repeat];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.