0
votes

I am new to cocos2d .Can any one suggest me a method to give animation for the transition between one frame to another frame. this is my code to fetch frames and just display

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

How to do the animation for the transition between frames

thanks in advance

1
In the code => CCAnimation *walkAnim = [CCAnimation animationWithFrames:walkAnimFrames delay:0.1f]; The delay is used for the transition from one frame to another. Please go through the ray wenderlich tutorial for cocos2d. - Marine
yea we can give the delay but awt abt the animation - rahul raj
I'm not sure I understand what you want... But to run the animation, just do [self.sprite runAction:self.walkAction]; - sdabet

1 Answers

0
votes

You can not "transition" (morph) between two frames (images), if that's what you mean.

It sounds to me like you want something that's called keyframe interpolation, which is normally used in 3D animations. A 2D animation displays one frame after another. You can not interpolate between two frames graphically (morphing), you can only interpolate properties like position.