2009-07-21 14 views
0

私は、このコードスニペットを見つけた:アニメーションでCATransactionを使用するのはなぜですか?

[self setValue:direction forKey:@"currentDirection"]; 

CAKeyframeAnimation * animation = [CAKeyframeAnimation animationWithKeyPath:@"position"]; 
animation.path = path; 
animation.duration = grids * gridWidth/[self speed]; 
animation.fillMode = kCAFillModeForwards; 
animation.removedOnCompletion = NO; 
animation.delegate = self; 
animation.calculationMode = kCAAnimationLinear; 
[self addAnimation:animation forKey:@"movement"]; 
self.position = destination; 

[CATransaction begin]; 
[CATransaction setValue:[NSNumber numberWithFloat:_turn_duration] 
              forKey:kCATransactionAnimationDuration]; 
eyes.position = eyeDestination; 
pupils.position = pupilDestination; 
[CATransaction commit]; 

CGPathRelease(path); 

ここCATransactionを使用してのポイントは何ですか?

答えて

2

トランザクション内の2つの暗黙のアニメーションの継続時間を、上記のキーフレームアニメーションの継続時間とは異なる値に設定するには、次のように入力します。トランザクション内のアニメーションは_turn_duration秒を超え、キーフレームアニメーションはgrids * gridWidth/[self speed]秒を超えて実行されます。

+0

したがって、CAKeyframeAnimationはアニメーションブロックですか? – Thanks

+0

いいえ、それはアニメーションです:Dアニメーションは、明示的または暗黙的にオブジェクトに適用されます。アニメーションをまとめてオブジェクトに明示的に適用することができます。今あなたがしたいのは、Core Animation Programming Guide、特に「アニメーション」の章から始まり、今後の予定です。 http://developer.apple.com/documentation/Cocoa/Conceptual/CoreAnimation_guide/Articles/AnimatingLayers.html –

関連する問題