1

我正在开发非常简单的游戏。一切正常。我只对性能和内存有疑问。我正在从左到右移动鸟。这只鸟在 3 个位置挥动翅膀。

关于速度,性能,内存有什么更好的解决方案:

  1. 动画 uiview 改变 3 张完整的图片,鸟和翅膀在不同的位置
  2. 使用 CALayer 动画创建鸟背景和动画单翼图像

感谢您的回复:) 亚历克斯

更新:更复杂的动画呢?

4

1 回答 1

0

Since you have only 3 images (as described in your question), you can go with simpler UIView animation approach.

But, using CoreAnimation will give you better performance.

When using 3 different images, instead of changing pictures and animating views, you can use animation property of UIImageView itself.

Say image01.png, image02.png and image03.png are your images.

    UIImageView *animationImgView = [[UIImageView alloc] init];
    NSArray *animationImages = [NSArray arrayWithObjects:
                                        [UIImage imageNamed:@"image01.png"],
                                        [UIImage imageNamed:@"image02.png"],
                                        [UIImage imageNamed:@"image03.png"],
                                        nil];
    [animationImgView setAnimationImages:animationImages];   // Add images to imageView for animation.
    [animationImgView setAnimationRepeatCount:0];           // Repeat forever.
    [animationImgView startAnimating];                     // ImageView starts animating.

Then animate position of UIImageView

于 2012-12-31T05:11:26.733 回答