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 ima开发者_运维知识库geNamed:@"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];
}
Add the line:
bigBoom.animationRepeatCount = 1;
精彩评论