2012-09-20 73 views
0

我是新来的cocos2d。任何人都可以给我一个方法来给出一帧到另一帧之间的过渡动​​画。 这是我的代码取帧和只显示如何在cocos2d中的框架spritesheet之间放置动画?

[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@“spritesheet.plist”];

// Create a sprite sheet with the Happy Bear images 
    CCSpriteBatchNode *spriteSheet = [CCSpriteBatchNode batchNodeWithFile:@"spritesheet.png"]; 
    [self addChild:spriteSheet]; 

    // Load up the frames of our animation 
    walkAnimFrames = [NSMutableArray array]; 
    for(int i = 1; i <=7; ++i) { 
     [walkAnimFrames addObject:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"sprite%d.png", i]]]; 
    } 
    CCAnimation *walkAnim = [CCAnimation animationWithFrames:walkAnimFrames delay:0.1f]; 

    // Create a sprite for our bear 
    CGSize winSize = [CCDirector sharedDirector].winSize; 
    self.sprite = [CCSprite spriteWithSpriteFrameName:@"sprite.png"]; 
    self.sprite.position=ccp(320,480); 
    self.sprite.anchorPoint=ccp(1,1); 
    self.walkAction = [CCAnimate actionWithAnimation:walkAnim restoreOriginalFrame:NO]; 

如何做动画帧

感谢之间的过渡提前

+0

在代码=> CCAnimation * walkAnim = [CCAnimation animationWithFrames:walkAnimFrames延迟:0.1F];延迟用于从一帧到另一帧的过渡。请阅读cocos2d的ray wenderlich教程。 – Marine

+0

是啊,我们可以给予延迟,但AWT ABT动画 –

+0

我不知道我知道你想要什么......但要运行动画,只是做'[self.sprite runAction:self.walkAction]' – fiddler

回答

0

你不能“过渡”(变身)两帧(图像)之间,如果这是你的意思。

像你想要的东西,这就是所谓的keyframe interpolation,这通常是在3D动画中使用这听起来我。 2D动画显示一帧又一帧。您不能以图形方式在两个帧之间进行插值(变形),只能插入像位置这样的属性。