开发者

Cocoa Touch - Play an Animation Once

开发者 https://www.devze.com 2023-01-10 05:13 出处:网络
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

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;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号