2012-09-11 28 views
0

我有一個CABasicAnimation.fromValue.toValue,在一個PNG圖像與圖像202移動,並通過一個CABasicAnimation與幀

也我用CALayer保持image.png顯示它們一項的陣列

,它通過序列 通過所有圖像的問題,我希望通過展示,我將放在一個NSArray

這裏幀圖像是我的代碼:

CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"sampleIndex"]; 
anim.fromValue = [NSNumber numberWithInt:1]; 
anim.toValue = [NSNumber numberWithInt:203]; 
anim.duration = 1.75f; 
anim.repeatCount = HUGE_VALF; 
anim.autoreverses = YES; 
[myImage addAnimation:anim forKey:nil]; 

和幀的陣列是:

frames = (753, 377, 798, 422) , 
    (706, 377, 751, 422) , 
    (659, 377, 704, 422) , 
    (612, 377, 657, 422) , 
    (565, 377, 610, 422) , 
    (518, 377, 563, 422) , 
    (518, 424, 563, 468) , 
    (471, 424, 516, 468) , 
    (424, 424, 469, 468) , 
    (471, 377, 516, 422) , 
    (424, 377, 469, 422) , 
    (377, 377, 422, 422) , 
    (330, 377, 375, 422) , 

等....

任何想法??

回答

1

與您的幀陣列類似,您可以將所有需要的圖像(幀)添加到UIImageView。這裏是例子:

NSArray *images = [NSArray arrayWithObjects: 
       [UIImage imageNamed:@"frame753.png"], 
       [UIImage imageNamed:@"frame377.png"], 
       [UIImage imageNamed:@"frame798.png"], 

       nil]; 
yourImageView.animationImages = images; 
yourImageView.animationDuration = 1.75; 
yourImageView.animationRepeatCount = 0; 
[yourImageViewstartAnimating]; 

希望這會有所幫助。

+0

我只有1圖像包含202圖像 – Mutawe

+0

考慮提取幀並保存爲單獨的圖像。 –

+0

我沒有工具給我通常相同的框架! – Mutawe