1
votes

I'm working on very simple game. Everything is working. I've only question about performance and memory. I'm moving bird from left to right. The bird waves his wings in 3 positions.

What's better solution regarding speed, performance, memory:

  1. animate uiview changing 3 complete pictures with bird and wing in differnet positions
  2. create bird background and animate single wing image using CALayer animation

Thanks for replies:) Alex

UPDATE: and what about more complex animations ??

1

1 Answers

0
votes

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