I have an app that uses the camera, with a gun image overlaid as well as a fire and reload button. On the retina iPad and iPhone, it cycles through 30 images in about a second for the firing animation, and 41 in 2 seconds for the reload animation. All of the images are 1920 x 1080, and on the iPhone they are 1000 x 533. To cycle through the .pngs when the fire button is tapped for example, I am using this in the PlayViewController.m file:
- (IBAction)fire:(id)sender {
// Play the firing animation for the rifle, enable reload button
fireButton.enabled = NO;
type.animationImages = gunanimload;
type.animationDuration = 1.0;
type.animationRepeatCount = 1;
reloadButton.enabled = YES;
[type startAnimating];
In the viewDidLoad method I create the array and load it with images:
- (void)viewDidLoad
{
[super viewDidLoad];
UIImage* img1 = [UIImage imageNamed:@"rev0001.png"];
... x30
gunanimload = [NSArray arrayWithObjects:img1, ... x30, nil];
}
Even though it should be loading the array when the view loads, it still seems to be doing it when the Fire button is tapped. How would I eliminate this delay? Or is there a (relatively simple) alternative to playing the fire and reload animations?