【问题标题】:How to create animation in cocos2d 3.0?cocos2d 3.0如何制作动画?
【发布时间】:2014-04-04 21:36:30
【问题描述】:

所以我尝试了

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

但后来我发现 CCRepeatForever 已被重命名,CCAnimate 已被删除。这个怎么换?

所有代码:http://pastebin.com/VnrtiCwb

【问题讨论】:

标签: cocos2d-iphone


【解决方案1】:

CCRepeatForever 替换为 CCActionRepeatForeverCCAnimate 替换为 CCActionAnimate

【讨论】:

    【解决方案2】:

    试试这个代码

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

    【讨论】:

      猜你喜欢
      • 2014-03-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多