0

使用核心圖形,我正在將圖像移動到預定義的路徑上。我可以使用多個圖像而不是一個來製作動畫嗎?

我想使用多個圖像,而不是一個,以實現動畫。 任何人都可以告訴我如何實現這一點(使用多個圖像,而不是一個)?

這是我的代碼與單個圖像:

bounceLayer = [CALayer layer]; 
bounceLayer.frame = CGRectMake(12, 12, 12, 12); 
[bounceLayer setPosition:CGPointMake(175.0f, 100.0f)]; 

bounceLayer.contents = (id) [UIImage imageNamed: 
           [NSString stringWithFormat:@"Avatar_%d.png",i]].CGImage; 
[[[self view] layer] addSublayer:bounceLayer]; 
[bounceLayer setPosition:CGPointMake(120.0f, 49.0f)]; 
[bounceLayer addAnimation:[self bounceAnimationPathWithDuration:3.0f] forKey:nil]; 

bounceAnimationPathWithDuration - 是它創建了一個路徑

函數這可能與核芯顯卡?還是應該使用Cocoa 2D?

+0

你能對你正在使用的圖像究竟如何實現動畫詳細點嗎?這是一個圖像序列? – oltman 2012-03-07 05:39:54

+0

另外,請嘗試接受一些你已經問過的問題的答案。 – 2012-03-07 06:07:37

回答

1

是的,你可以使用多個圖像,而不是一個,以實現動畫。卡通製作的方式。您甚至可以使用貝塞爾曲線在動畫中製作不同的圖像。它會像這樣 -

NSArray *animImages = [[NSArray alloc] initWithObjects: 
         [UIImage imageWithContentsOfFile: 
[[NSBundle mainBundle] pathForResource:@"SodaPour1" ofType:@"png"]], 
         [UIImage imageWithContentsOfFile: 
[[NSBundle mainBundle] pathForResource:@"SodaPour39" ofType:@"png"]], 
         nil]; 

imgGlass.animationImages = GlassAnim; 
imgGlass.animationDuration = 2.5; 
imgGlass.contentMode = UIViewContentModeScaleAspectFit; 
imgGlass.animationRepeatCount=1; 
[GlassAnim release]; 

也可以通過這個 - How to animate images using bitmaps/rgb data in iOS

+0

嗨斯里卡,Thx爲您提供幫助。我會盡力讓你知道。許多Thx。 – suj 2012-03-07 11:02:05

+0

斯里卡爾,對不起,問這個愚蠢的問題可能是... 你能告訴我如何聯繫你的建議,以取代這一行代碼,因此我加載多個圖像到我的圖層,而不是隻有一個... bounceLayer .contents =(id)[UIImage imageNamed:@「img.png」]。CGImage; – suj 2012-03-07 11:16:35

+0

是什麼問題? – 2012-03-07 11:17:33

相關問題