Hey jucao,
I would have done this using Cocos2d, as I didn't bother messing with any of the Core Graphics or controls that apple gives you by default..
you set up several sprites, and then a time interval and start/stop animation whenever you'd like. It works great for a bullet in my game that "flips about the X axis". Cocos gives you a way to do that using some of their image transforms, but it looks sketchy, like a 2d image being rotated 3 dimensionally; crappy for the effect we want. So I created 5 frames that represent the 3d rotating action, and it came together quite nice, similar to this:
// this assumes you have a Sprite created elsewhere named "sbullet"
// created something like this
// Sprite* sbullet = [[Sprite spriteWithFile:@"bullet.png"] retain];
//animation action specified with 1/10 of a second delay between frames.
//So 10 frames per second essentially.. worked for me, change to your needs.
|
id animation = [Animation animationWithName:@"spinning_bullet" delay:0.1f];
//I have 5 images spinning_bullet_0.png - spinning_bullet_1.png, which i add to the animation |
for( int i=1;i<15;i++)
|
[animation addFrame: [NSString stringWithFormat:@"spinning_bullet_%0.png", i]];
|
|
//the magic of cocos2d Actions!!! |
id action = [Animate actionWithAnimation: animation];
|
|
//animate the bullet |
|
[sbullet runAction:action]; |
There is apparently a way to achieve image animations using what apple gives you; CABasicAnimation.. Check out a use here(only rotates however)
CABasicAnimation might be worth investigating..
Hope this helps..