Cocos2d iphone 动画帮助!

Cocos2d iphone 动画帮助!,cocos2d-iphone,Cocos2d Iphone,我有个简单的问题。我正在使用cAnimation浏览一系列图像,以制作一个足球螺旋。像这样: // load the football's animation frames as textures and create a sprite frame frames = [[NSMutableArray alloc]initWithCapacity:3]; for (int i = 0; i < 10; i++) { NSString* file = [NSString stringWithF

我有个简单的问题。我正在使用cAnimation浏览一系列图像,以制作一个足球螺旋。像这样:

// load the football's animation frames as textures and create a sprite frame
frames = [[NSMutableArray alloc]initWithCapacity:3];
for (int i = 0; i < 10; i++)
{
NSString* file = [NSString stringWithFormat:@"Football%i.png", i];
CCTexture2D* texture = [[CCTextureCache sharedTextureCache] addImage:file];
CGSize texSize = texture.contentSize;
CGRect texRect = CGRectMake(0, 0, texSize.width, texSize.height);
CCSpriteFrame* frame = [CCSpriteFrame frameWithTexture:texture rect:texRect];
[frames addObject:frame];
}

// create an animation object from all the sprite animation frames
CCAnimation* anim = [CCAnimation animationWithFrames:frames delay:0.03f];

// run the animation by using the CCAnimate action
CCAnimate* animate = [CCAnimate actionWithAnimation:anim];
CCRepeatForever* repeat = [CCRepeatForever actionWithAction:animate];
[self runAction:repeat];
//加载足球动画帧作为纹理,并创建精灵帧
frames=[[NSMutableArray alloc]initWithCapacity:3];
对于(int i=0;i<10;i++)
{
NSString*文件=[NSString stringWithFormat:@“Football%i.png”,i];
CCTexture2D*纹理=[[CCTextureCache sharedTextureCache]addImage:file];
CGSize texSize=texture.contentSize;
CGRect texRect=CGRectMake(0,0,texSize.width,texSize.height);
CCSpriteFrame*frame=[CCSpriteFrame frameWithTexture:texture rect:texRect];
[帧添加对象:帧];
}
//从所有精灵动画帧创建动画对象
CCAnimation*anim=[CCAnimation animation withframes:frames delay:0.03f];
//使用CCAnimate操作运行动画
CCAnimate*animate=[CCAnimate actionWithAnimation:anim];
CCRepeatForever*repeat=[CCRepeatForever actionWithAction:animate];
[自我运行:重复];

这真的很好,但我想知道如何用相同的阵列创建另一个动画,使足球看起来像是慢慢停止旋转?我知道延迟:0.03f控制着球旋转的速度,所以有没有办法让延迟缓慢地结束在0.0f,或者有没有其他方法呢?

你可以简单地使用
[animate setDuration:[animate getDuration]+0.1]
来增加延迟时间。你必须增加延迟时间,使足球看起来旋转得更慢。过了一段时间,你就停止去激活动画。如果您想使用动画帧创建另一个动画,您可以调用
[cAnimation AnimationWithFrames:[anim getFrames]]

我按您所说的做了,但它似乎没有访问动画。我用这段代码创建了一个方法[anim setDelay:[anim delay]+0.1];还有另一种方法来安排比赛,比赛正在进行,但足球仍在全速旋转。我做错了什么?对不起,我犯了错误并更正了我的答案你必须更改动画实例的持续时间而不是动画的延迟,当然如果你想从中创建另一个动画,你也必须更改延迟,但在你的情况下,似乎只更改持续时间就足够了(这次我自己测试了)