所以我试过
self.walkAction = [CCRepeatForever actionWithAction: [CCAnimate actionWithAnimation:walkAnim]];
但后来我发现CCRepeatForever已被重命名并且CCAnimate已被删除。我该如何替换它?
答案 0 :(得分:1)
CCRepeatForever
已替换为CCActionRepeatForever
,CCAnimate
替换为CCActionAnimate
答案 1 :(得分:0)
试试这段代码
CCSprite *sprite = [CCSprite spriteWithImageNamed:@"sv_anim_1.png"]; // comes from your .plist file
sprite.position = ccp( [[CCDirector sharedDirector] viewSize].width/2, [[CCDirector sharedDirector] viewSize].height/2 );
CCSpriteBatchNode *batchNode = [CCSpriteBatchNode batchNodeWithFile:@"scene1atlas.png"];
[batchNode addChild:sprite];
[self addChild:batchNode];
NSMutableArray *animFrames = [NSMutableArray array];
for(int i = 1; i < 5; i++)
{
//NSString *str=[NSString stringWithFormat:@"an1_anim%d.png",i];
CCSpriteFrame *frame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"an1_anim%d.png",i]];
[animFrames addObject:frame];
}
animation = [CCAnimation animationWithSpriteFrames:animFrames delay:0.2f];
[sprite runAction:[CCActionRepeatForever actionWithAction:[CCActionAnimate actionWithAnimation:animation]]];