Reputation: 45
So I tried
self.walkAction = [CCRepeatForever actionWithAction: [CCAnimate actionWithAnimation:walkAnim]];
But then I discovered that CCRepeatForever has been renamed and CCAnimate removed. How can I replace this?
All code: http://pastebin.com/VnrtiCwb
Upvotes: 0
Views: 1764
Reputation: 136
CCRepeatForever
was replaced with CCActionRepeatForever
and CCAnimate
with CCActionAnimate
Upvotes: 1
Reputation: 3928
try this code
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]]];
Upvotes: 0