2013-03-09 35 views
0

我使用下面的代碼如何在循環播放圖像序列,反序

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
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]; 
+0

那真是太愚蠢了......謝謝Rushi。這是一件非常簡單的事情,我應該想到。 – iscavengers 2013-03-09 11:26:56