tags:

views:

20

answers:

1

I have this code but it plays an animation on a loop and I only want it to play once.

Any help?

-(void)gameOver{ //blow up ship 

    //animate explostion
    UIImage *firstBoom = [UIImage imageNamed:@"Explo_0.png"];
    UIImageView *bigBoom = [[UIImageView alloc] initWithImage:firstBoom];
    bigBoom.animationImages = [NSArray arrayWithObjects:
                                 [UIImage imageNamed:@"Explo_1.png"],
                                 [UIImage imageNamed:@"Explo_1.png"],
                                 [UIImage imageNamed:@"Explo_1.png"],
                                 [UIImage imageNamed:@"Explo_2.png"],
                                 [UIImage imageNamed:@"Explo_2.png"],
                                 [UIImage imageNamed:@"Explo_2.png"],
                                 [UIImage imageNamed:@"Explo_3.png"],
                                 [UIImage imageNamed:@"Explo_3.png"],
                                 [UIImage imageNamed:@"Explo_3.png"],
                                 [UIImage imageNamed:@"Explo_4.png"],
                                 [UIImage imageNamed:@"Explo_4.png"],
                                 [UIImage imageNamed:@"Explo_4.png"],
                                 [UIImage imageNamed:@"Explo_4.png"],
                                 [UIImage imageNamed:@"Explo_4.png"],
                                 nil];
    bigBoom.center = CGPointMake(xCoordinate, yCoordinate); //so it explodes ontop of the ship

    [bigBoom startAnimating];
    [self.view addSubview:bigBoom];
    [shipImageView setHidden:YES];
}
+1  A: 

Add the line:

bigBoom.animationRepeatCount = 1;
Seamus Campbell
works great pretty easy too. i'll accept this answer later i have to wait.