2015-02-07 37 views
0

我用將圖像製作爲我的應用的最佳方式是什麼?

image.animationImages = [NSArray arrayWithObjects: 
          [UIImage imageNamed:@"image1"], 
          [UIImage imageNamed:@"image2"], 
          [UIImage imageNamed:@"image3"], 
          [UIImage imageNamed:@"image4"], nil]; 


[image setAnimationRepeatCount:1]; 
image.animationDuration = 1; 
[image startAnimating]; 

,但它給出了一個翻轉書的效果動畫。我正在尋找的是在給定時間設置每張圖像的流暢動畫。我目前是NSTimers來觸發一個方法,然後我有方法內的代碼設置圖像和另一個NSTimer設置另一個圖像,這是在方法中的第四個。它提供了我正在尋找的動畫,但是我面臨的問題是我正在開發一款遊戲,並且我希望當用戶暫停遊戲時停止當前的圖像。遊戲運行在觸發方法的NSTimer上。我所做的暫停遊戲是讓NSTimer失效。

我應該採取什麼方法?

回答

0

您應該添加NSTimer和user_flag輸入。
這個user_flag輸入可以聲明爲static int user_flag = 0 當你停止時,只需將該變量設爲user_flag = 1即可。

現在實現所有這些條件的邏輯,這將是這個樣子之一:

if(NSTimer_obj == condition && user_flag == 0) 
{ 
     //your code... 

} 
+0

你能給我一個例子我是一個有點困惑@Sandeep Jangir – 2015-02-07 23:35:57

+0

我的代碼運動= [的NSTimer scheduledTimerWithTimeInterval:0.05目標:self selector:@selector(method)userInfo:nil repeatats:YES]; - (void)方法{movement = [NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(method2)userInfo:nil repeatats:NO]; // image .. { - (void)method2 {// image2 ... {@Sandeep Jangir – 2015-02-07 23:37:25

相關問題