@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
}
- (IBAction)Drink:(UIButton *)sender {
[selftomCatAnimationWithName:@"drink" withCount:81];
/* NSMutableArray *images =[NSMutableArray array];
for (NSInteger i = 0; i < 81; i++){
//根據(jù)i來加載圖片娜谊,然后添加到可變數(shù)字images里面
NSString *imageName = [NSStringstringWithFormat:@"drink_%02ld.jpg",i];
UIImage *image = [UIImageimageNamed:imageName];
//講圖片image添加到數(shù)組images中
[images addObject:image];
}
self.tomCatView.animationImages =images;
//設(shè)置動(dòng)畫時(shí)長(zhǎng)
self.tomCatView.animationDuration =40*0.075;
//設(shè)置動(dòng)畫重復(fù)次數(shù)
self.tomCatView.animationDuration =1;
//開始動(dòng)畫
[self.tomCatView startAnimating];
*/
}
- (IBAction)cymbal:(UIButton *)sender {
NSMutableArray *images =[NSMutableArray array];
for (NSInteger i = 0; i < 81; i++){
//根據(jù)i來加載圖片丈攒,然后添加到可變數(shù)字images里面
NSString *imageName = [NSStringstringWithFormat:@"cymbal_%02ld.jpg",i];
UIImage *image = [UIImageimageNamed:imageName];
//講圖片image添加到數(shù)組images中
[imagesaddObject:image];
}
self.tomCatView.animationImages =images;
//設(shè)置動(dòng)畫時(shí)長(zhǎng)
self.tomCatView.animationDuration= 40*0.075;
//設(shè)置動(dòng)畫重復(fù)次數(shù)
self.tomCatView.animationDuration= 1;
//開始動(dòng)畫
[self.tomCatViewstartAnimating];
}
- (IBAction)fart:(UIButton *)sender {
NSMutableArray *images =[NSMutableArray array];
for (NSInteger i = 0; i < 81;i++) {
//根據(jù)i來加載圖片,然后添加到可變數(shù)字images里面
NSString *imageName =[NSString stringWithFormat:@"fart_%02ld.jpg",i];
UIImage *image = [UIImageimageNamed:imageName];
//講圖片image添加到數(shù)組images中
[imagesaddObject:image];
}self.tomCatView.animationImages= images;
//設(shè)置動(dòng)畫時(shí)長(zhǎng)
self.tomCatView.animationDuration =40*0.075;
//設(shè)置動(dòng)畫重復(fù)次數(shù)
self.tomCatView.animationDuration =1;
//開始動(dòng)畫
[self.tomCatView startAnimating];
}
- (IBAction)pie:(UIButton*)sender {
NSMutableArray *images =[NSMutableArray array];
for (NSInteger i = 0; i <81; i++) {
//根據(jù)i來加載圖片柳譬,然后添加到可變數(shù)字images里面
NSString *imageName =[NSString stringWithFormat:@"pie_%02ld.jpg",i];
UIImage *image = [UIImageimageNamed:imageName];
//講圖片image添加到數(shù)組images中
[images addObject:image];
}
self.tomCatView.animationImages = images;
//設(shè)置動(dòng)畫時(shí)長(zhǎng)
self.tomCatView.animationDuration = 40*0.075;
//設(shè)置動(dòng)畫重復(fù)次數(shù)
self.tomCatView.animationDuration = 1;
//開始動(dòng)畫
[self.tomCatViewstartAnimating];
}
- (IBAction)scratch:(UIButton*)sender {
NSMutableArray *images =[NSMutableArray array];
for (NSInteger i = 0; i< 81; i++) {
//根據(jù)i來加載圖片,然后添加到可變數(shù)字images里面
NSString *imageName =[NSString stringWithFormat:@"scratch_%02ld.jpg",i];
UIImage *image =[UIImage imageNamed:imageName];
//講圖片image添加到數(shù)組images中
[imagesaddObject:image];
}
self.tomCatView.animationImages = images;
//設(shè)置動(dòng)畫時(shí)長(zhǎng)
self.tomCatView.animationDuration = 40*0.075;
//設(shè)置動(dòng)畫重復(fù)次數(shù)
self.tomCatView.animationDuration = 1;
//開始動(dòng)畫
[self.tomCatViewstartAnimating];
}
- (IBAction)eatbirdAction:(UIButton*)sender {
//創(chuàng)建可變數(shù)組images刘绣,負(fù)責(zé)存放要播放圖片數(shù)組
NSMutableArray *images =[NSMutableArray array];
for (NSInteger i = 0; i < 40;i++) {
//根據(jù)i來加載圖片瓦戚,然后添加到可變數(shù)字images里面
NSString *imageName =[NSString stringWithFormat:@"eat_%02ld.jpg",i];
UIImage *image = [UIImageimageNamed:imageName];
//講圖片image添加到數(shù)組images中
[imagesaddObject:image];
}
self.tomCatView.animationImages =images;
//設(shè)置動(dòng)畫時(shí)長(zhǎng)
self.tomCatView.animationDuration= 40*0.075;
//設(shè)置動(dòng)畫重復(fù)次數(shù)
self.tomCatView.animationDuration= 1;
[self.tomCatViewstartAnimating];
//開始動(dòng)畫
[self.tomCatViewstartAnimating];
}
-(void)tomCatAnimationWithName:(NSString*)name withCount:(NSInteger)count
{//創(chuàng)建可變數(shù)組images,負(fù)責(zé)存放要播放圖片數(shù)組
if ([self.tomCatView isAnimating]){
return;
}
NSMutableArray *images =[NSMutableArray array];
for (NSInteger i = 0; i < count; i++) {
//根據(jù)i來加載圖片蕾羊,然后添加到可變數(shù)字images里面
NSString *imageName = [NSStringstringWithFormat:@"%@_%02ld.jpg",name,i];
UIImage *image = [UIImageimageNamed:imageName];
//講圖片image添加到數(shù)組images中
[images addObject:image];
}
self.tomCatView.animationImages =images;
//設(shè)置動(dòng)畫時(shí)長(zhǎng)
self.tomCatView.animationDuration =count*0.075;
//設(shè)置動(dòng)畫重復(fù)次數(shù)
self.tomCatView.animationDuration =1;
[self.tomCatView startAnimating];
}
- (IBAction)eataction:(UIButton *)sender {
//創(chuàng)建可變數(shù)組images,負(fù)責(zé)存放要播放圖片數(shù)組
NSMutableArray *images =[NSMutableArray array];
for (NSInteger i = 0; i < 40; i++){
//根據(jù)i來加載圖片帽驯,然后添加到可變數(shù)字images里面
NSString *imageName = [NSStringstringWithFormat:@"eat_%02ld.jpg",i];
UIImage *image = [UIImageimageNamed:imageName];
//講圖片image添加到數(shù)組images中
[images addObject:image];
}
self.tomCatView.animationImages =images;
//設(shè)置動(dòng)畫時(shí)長(zhǎng)
self.tomCatView.animationDuration =40*0.075;
//設(shè)置動(dòng)畫重復(fù)次數(shù)
self.tomCatView.animationDuration =1;
[self.tomCatViewstartAnimating];
//開始動(dòng)畫
[self.tomCatViewstartAnimating];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that canbe recreated.
}
@end