如何在循环中播放图像序列,反向顺序

时间:2013-03-09 11:16:17

标签: iphone

我正在使用以下代码

    UIImageView* campFireView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 175, 175)];
     // load all the frames of our animation
     campFireView.animationImages = [NSArray arrayWithObjects:
                                     [UIImage imageNamed:@"a1.png"],
                                     [UIImage imageNamed:@"a2.png"],
                                     [UIImage imageNamed:@"a3.png"],
                                     [UIImage imageNamed:@"a4.png"],
                                     [UIImage imageNamed:@"a5.png"],
                                     [UIImage imageNamed:@"a6.png"],
                                     [UIImage imageNamed:@"a7.png"],
                                     [UIImage imageNamed:@"a8.png"],
                                     [UIImage imageNamed:@"a9.png"],
                                     [UIImage imageNamed:@"a10.png"],
                                     nil];

     // all frames will execute in 1.75 seconds
     campFireView.animationDuration = 0.75;
     // repeat the annimation forever
     campFireView.animationRepeatCount = 0;
     // start animating
     [campFireView startAnimating];
     // add the animation view to the main window 
     [self.view addSubview:campFireView];   //  [campFireView release];

这适用于a1到a10, 我怎样才能继续按相反的顺序移动,那么它应该将a1设置为a10到a1连续动画吗?

1 个答案:

答案 0 :(得分:1)

campFireView.animationImages = [NSArray arrayWithObjects:
                                [UIImage imageNamed:@"a1.png"],
                                [UIImage imageNamed:@"a2.png"],
                                [UIImage imageNamed:@"a3.png"],
                                [UIImage imageNamed:@"a4.png"],
                                [UIImage imageNamed:@"a5.png"],
                                [UIImage imageNamed:@"a6.png"],
                                [UIImage imageNamed:@"a7.png"],
                                [UIImage imageNamed:@"a8.png"],
                                [UIImage imageNamed:@"a9.png"],
                                [UIImage imageNamed:@"a10.png"],
                                [UIImage imageNamed:@"a9.png"],
                                [UIImage imageNamed:@"a8.png"],
                                [UIImage imageNamed:@"a7.png"],
                                [UIImage imageNamed:@"a6.png"],
                                [UIImage imageNamed:@"a5.png"],
                                [UIImage imageNamed:@"a4.png"],
                                [UIImage imageNamed:@"a3.png"],
                                [UIImage imageNamed:@"a2.png"],
                                [UIImage imageNamed:@"a1.png"],
                                nil];