0

コア グラフィックスを使用して、定義済みのパス上で画像を移動しています。

アニメーションを実現するために、1 つではなく複数の画像を使用したいと考えています。これを達成する方法を教えてもらえますか(1つではなく複数の画像を使用)?

これは単一の画像を含む私のコードです:

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

ounceAnimationPathWithDuration - パスを作成する関数です

これは Core グラフィックスで可能ですか? または、Cocoa 2D を使用する必要がありますか?

4

1 に答える 1

1

はい、アニメーションを実現するために、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];

また、これを確認することもできます - iOS でビットマップ / RGB データを使用して画像をアニメーション化する方法

于 2012-03-07T06:05:58.267 に答える