views:

568

answers:

1

I'd like help on some strategies to sequence some animations.

I subclassed UIImageView so that I could write some custom animation actions on an image. I implemented a few methods to be used as actions that I could call on my image example:

-(void)rotateAnim; //rotates the image by a few degrees using a CGAffine Transform

-(void)numbersFlashAnim; //uses the UIImageVew.animationImages array for a 14 frame animation.

-(void)moveLeftAnim; //uses another CGAffine Transform to change the imageView's position.

In my viewDidLoad method I create an instance of my UIImageView subclass. What ways exist to call these animations in sequence?

I was thinking about using an NSTimer to handle the animations, but wasn't sure if you could write an NSTimer object to handle multiple method calls.

example:

[imageView rotateAnim]; //when this animation is done, I want to call:
[imageView numbersFlashAnim];

I've seen several questions regarding the use of an NSTimer, but none that specifically relate to this problem. Note: I saw that the dev docs on apple's site also recommend the use of the performSelector:withObject:afterDelay: in some cases but was wondering if that would offer enough flexibility.

Additionally, I've already taken a look at the Cocos2d framework, and although I can use their methods ~(Sequence actions: etc, ) I'm choosing to solve this problem with UIKit/Foundation, etc.

A: 

Do you use animation? I mean you can rotate your image inside [UIView beginAnimations:(NSString *)animationID context:(void *)context] block. There you can add a delegate method that will be called after current animation ends. And there you can call your numbersFlashAnim. (Sorry for my english ;-) )

Morion
Yes, I used an animation block and wrapped in a method so i could call the entire animation with one line of code. I haven't added any delegates. so i'll check for that. Could I use the animation delegate for the animationFrames as well?
samfu_1
Hmm. Sorry, but I cannot understand what do you mean under animationFrames. You can call rotation of your imageView inside te animation block. Then you can set a method with the second part pf your animation, that will be fired after your animation will be finished.
Morion