Posts Tagged ‘animation’

simple cocos2d animation using .png sequence

Posted in code on March 6th, 2012 by admin – Be the first to comment

Right, so I do a lot of animation in my apps, so here is the most simple creation of it

yourfile.h

@private CCSprite *youranimref;
@private CCAnimation *animation;

yourfile.m

-(id) init
{
    if( (self=[super init] )) {
       
        self.isTouchEnabled = YES;
       
        size = [[CCDirector sharedDirector] winSize];
       
        // DECLARE ANIMATION
        animation = [[CCAnimation alloc] initWithName:@"youranimref" delay:1/24.0];
        youranimref = [CCSprite spriteWithFile:@"yourFirstAnimGrfx.png"];
        [animation addFrameWithFilename: @"yourSecondAnimGrfx.png"];
        [animation addFrameWithFilename: @"yourThirdAnimGrfx.png"];
        [animation addFrameWithFilename: @"yourFourthAnimGrfx.png"];

       
        // ADD ANIMATION
        youranimref.position = ccp( 512, 435 );
        [self addChild:youranimref z:5];

    }
    return self;
}


- (void) dealloc
{

// !!!!! VERY IMPORTANT - REMOVE TEXTURES AND RELEASE REFERENCE TO THE ANIMATION

    [[CCTextureCache sharedTextureCache] removeUnusedTextures];
    [[CCSpriteFrameCache sharedSpriteFrameCache] removeUnusedSpriteFrames];

    // RELEASE RETAINED OBJECTS
    [animation release];
   
    [super dealloc];
}

- (void) runAnimation
{
   
    // RUN THE ANIMATION
   
    CCAnimate* action = [CCAnimate actionWithAnimation:animation];
    [youranimref runAction:action];

}

side walk loop

Posted in Uncategorized on September 27th, 2010 by matt – Be the first to comment

rough vs final

moar animation

Posted in Uncategorized on September 23rd, 2010 by matt – Be the first to comment

look! perspective n whatnot!

walk+hat tip

Its been an interesting ride thus far. Really struggled with the first completed animation, had to go away and think about it for a bit, do some research (finally had a reason to read richard willams 2d animation book). Realized I was jumping the gun and making lovely finished single frames before finishing the animation, which was never gonna fly. Bit of a refresher on walk cycles, drawing in ‘wireframe’ essentially, all coming together much faster now.

he moves!

Posted in Uncategorized on June 18th, 2010 by matt – Be the first to comment

and this marks my first 2d animation since… i can’t even remember. do stick figures in high-school textbooks count?

tippy tap

cocos2d sprite animation

Posted in code on June 2nd, 2010 by lucy – Be the first to comment

Next stop, sprite animation. I’m going to check out this tutorial.

http://getsetgames.com/2010/04/18/how-to-animate-sprites-in-cocos2d/