我必须animate(dancing)一个character(guy)大约6-7秒,即500-600帧.我以前做过动画,我使用zwoptex创建了spritesheets,然后在伟大的雷·温德利希的帮助下用CCSpriteFrameCache && CCSpriteBatchNode加载了它。但是在这种情况下,帧的数目很重,我不确定iOS设备是否能够支持它。用尽可能少的开销来动画所有这些帧的最佳过程是什么?我可以在动画时更改fps吗?有人知道吗??
发布于 2013-07-17 12:21:56
在这里,我放置了用于添加动画图像而不使用TexturePacker的代码
CCSprite *dog = [CCSprite spriteWithFile:@"dog1.gif"];
dog.position = ccp(winSize.width/2, winSize.height/2);
[self addChild:dog z:2];
NSMutableArray *animFrames = [NSMutableArray array];
for( int i=1;i<=5;i++)
{
NSString* file = [NSString stringWithFormat:@"dog%d.gif", 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];
[animFrames addObject:frame];
}
CCAnimation * animation = [CCAnimation animationWithSpriteFrames:animFrames];
animation.delayPerUnit = 0.07f;
animation.restoreOriginalFrame = YES;
CCAnimate *animAction = [CCRepeatForever actionWithAction:[CCAnimate actionWithAnimation:animation]];
[dog runAction:animAction];尝试使用这段代码,我不确定对您的情况是否有帮助:
https://stackoverflow.com/questions/17699384
复制相似问题