2014-02-06 5 views
0

Так что я попыталсяКак создать анимацию в cocos2d 3.0?

self.walkAction = [CCRepeatForever actionWithAction: [CCAnimate actionWithAnimation:walkAnim]]; 

Но потом я обнаружил, что CCRepeatForever был переименован и CCAnimate удалены. Как я могу это заменить?

Весь код: http://pastebin.com/VnrtiCwb

+0

CCActionRepeatForever, CCActionAnimate .. http://www.cocos2d-iphone.org /api-ref/3.0-rc1/ – LearnCocos2D

+0

Вы также можете использовать CCAnimatedSprite, который делает это очень простым: https://www.makegameswith.us/gamernews/331/ccanimatedsprite-the-easiest-way -в-одушевленные-а-спр –

ответ

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]]]; 
1

CCRepeatForever был заменен CCActionRepeatForever и CCAnimate с CCActionAnimate

Смежные вопросы