I've successfully loaded and used AtlasSprites with AtlasSpriteManager.
now I'm trying to do a simple 4-frame animation.
I have a Player class that is a sub-class of CocosNode.
It has the following declared as properties (all synthesized):
AtlasSprite *sprite;
AtlasSpriteManager *spriteManager;
AtlasAnimation *animation;
I was using a single AtlasSprite and added the animation to it. In doing so, I also compiled the image when it was added to the project - to make sure it is referenced properly.
In my init method, I've setup the objects above:
spriteManager = [AtlasSpriteManager spriteManagerWithFile:@"player_sprite"];
AtlasSprite *tempSprite = [AtlasSprite spriteWithRect:CGRectMake(0, 0, 64, 64) spriteManager:spriteManager];
self.sprite = tempSprite;
[tempSprite release];
[spriteManager addChild:sprite];
[self addChild:spriteManager];
// animation
AtlasAnimation *tempAnimation = [AtlasAnimation animationWithName:@"moving" delay:0.2f];
self.animation = tempAnimation;
[tempAnimation release];
[animation addFrameWithRect:CGRectMake(0, 0, 63, 63)];
[animation addFrameWithRect:CGRectMake(64, 0, 63, 63)];
[animation addFrameWithRect:CGRectMake(128, 0, 63, 63)];
[animation addFrameWithRect:CGRectMake(192, 0, 63, 63)];
In another part of the class, there is a method that can be called to start the animation:
-(void) startMoving {
id action = [Animate actionWithAnimation:animation];
[sprite runAction:action];
}
The program works fine up to the last line of code. I'm fairly certain the image dimensions are correct. I even reduced it to two frames, and made the dimensions substantially smaller to test it. Still no go. If I don't call the startMoving method, the initial image of the sprite shows, so it's the correct image file.