views:

77

answers:

1

Is there any other way to do animations besides my below code? I'm asking because I'm going to have some pretty intense animations that could get up to 20-30 frames. I'm also wondering if it's possible to play a sound with each frame?

popup.animationImages = [NSArray arrayWithObjects:
                                 [UIImage imageNamed:@"picture1.png"],
                                 [UIImage imageNamed:@"picture2.png"],
                                 [UIImage imageNamed:@"picture3.png"],
                                 [UIImage imageNamed:@"picture4.png"],
                                 [UIImage imageNamed:@"picture5.png"],
                                 [UIImage imageNamed:@"picture6.png"],
                                 [UIImage imageNamed:@"picture7.png"], nil];
        popup.animationDuration = 1.750567;
        popup.animationRepeatCount = 1;
        [popup startAnimating];
        [self.view addSubview:popup];
+1  A: 

Well, short of something like

(NSArray *) createAnimationArrayWithFileStem:(NSString *) stem firstFrame:(int) firstFrame lastFrame:(int) lastFrame{
    NSMutableArray *animationArray = [[NSMutableArray alloc] init];
    for (int currentFrame=firstFrame;currentFrame<=lastFrame;currentFrame++){
        [animationArray addObject:[UIImage imageNamed:[NSString stringWithFormat:@"%@%d.png",stem,currentFrame]];
    }
    [animationArray addObject:nil];
    [animationArray autorelease];
    return animationArray;
}

Or something very much like that, would allow you to just do

popup.images = [self createAnimationArrayWithFileStem:@"picture" firstFrame:1 lastFrame:7];
buggles
Just another note, setting up a Photoshop macro to dump out the frames from separate layers would help on the other side too. However, you may not be using PS.
buggles
Just re-read your full question... you don't seem to be able to set up a delegate to be notified of image changes. This would drive me towards a slightly different solution. I might (if I were you) set up a timer that fires at the desired playback rate and cycle through the images myself. This would allow me to play a sound as I update the image. However, you want to play a long sequence of images with sound? How about just playing the movie :-)
buggles
how do you turn a bunch of images into movie format? iMovie?
NextRev
I would use Adobe AfterEffects, but others may know of cheaper tools.
buggles