@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++){
//根据i来加载图片,然后添加到可变数字images里面
NSString *imageName = [NSStringstringWithFormat:@"drink_%02ld.jpg",i];
UIImage *image = [UIImageimageNamed:imageName];
//讲图片image添加到数组images中
[images addObject:image];
}
self.tomCatView.animationImages =images;
//设置动画时长
self.tomCatView.animationDuration =40*0.075;
//设置动画重复次数
self.tomCatView.animationDuration =1;
//开始动画
[self.tomCatView startAnimating];
*/
}
- (IBAction)cymbal:(UIButton *)sender {
NSMutableArray *images =[NSMutableArray array];
for (NSInteger i = 0; i < 81; i++){
//根据i来加载图片,然后添加到可变数字images里面
NSString *imageName = [NSStringstringWithFormat:@"cymbal_%02ld.jpg",i];
UIImage *image = [UIImageimageNamed:imageName];
//讲图片image添加到数组images中
[imagesaddObject:image];
}
self.tomCatView.animationImages =images;
//设置动画时长
self.tomCatView.animationDuration= 40*0.075;
//设置动画重复次数
self.tomCatView.animationDuration= 1;
//开始动画
[self.tomCatViewstartAnimating];
}
- (IBAction)fart:(UIButton *)sender {
NSMutableArray *images =[NSMutableArray array];
for (NSInteger i = 0; i < 81;i++) {
//根据i来加载图片,然后添加到可变数字images里面
NSString *imageName =[NSString stringWithFormat:@"fart_%02ld.jpg",i];
UIImage *image = [UIImageimageNamed:imageName];
//讲图片image添加到数组images中
[imagesaddObject:image];
}self.tomCatView.animationImages= images;
//设置动画时长
self.tomCatView.animationDuration =40*0.075;
//设置动画重复次数
self.tomCatView.animationDuration =1;
//开始动画
[self.tomCatView startAnimating];
}
- (IBAction)pie:(UIButton*)sender {
NSMutableArray *images =[NSMutableArray array];
for (NSInteger i = 0; i <81; i++) {
//根据i来加载图片,然后添加到可变数字images里面
NSString *imageName =[NSString stringWithFormat:@"pie_%02ld.jpg",i];
UIImage *image = [UIImageimageNamed:imageName];
//讲图片image添加到数组images中
[images addObject:image];
}
self.tomCatView.animationImages = images;
//设置动画时长
self.tomCatView.animationDuration = 40*0.075;
//设置动画重复次数
self.tomCatView.animationDuration = 1;
//开始动画
[self.tomCatViewstartAnimating];
}
- (IBAction)scratch:(UIButton*)sender {
NSMutableArray *images =[NSMutableArray array];
for (NSInteger i = 0; i< 81; i++) {
//根据i来加载图片,然后添加到可变数字images里面
NSString *imageName =[NSString stringWithFormat:@"scratch_%02ld.jpg",i];
UIImage *image =[UIImage imageNamed:imageName];
//讲图片image添加到数组images中
[imagesaddObject:image];
}
self.tomCatView.animationImages = images;
//设置动画时长
self.tomCatView.animationDuration = 40*0.075;
//设置动画重复次数
self.tomCatView.animationDuration = 1;
//开始动画
[self.tomCatViewstartAnimating];
}
- (IBAction)eatbirdAction:(UIButton*)sender {
//创建可变数组images,负责存放要播放图片数组
NSMutableArray *images =[NSMutableArray array];
for (NSInteger i = 0; i < 40;i++) {
//根据i来加载图片,然后添加到可变数字images里面
NSString *imageName =[NSString stringWithFormat:@"eat_%02ld.jpg",i];
UIImage *image = [UIImageimageNamed:imageName];
//讲图片image添加到数组images中
[imagesaddObject:image];
}
self.tomCatView.animationImages =images;
//设置动画时长
self.tomCatView.animationDuration= 40*0.075;
//设置动画重复次数
self.tomCatView.animationDuration= 1;
[self.tomCatViewstartAnimating];
//开始动画
[self.tomCatViewstartAnimating];
}
-(void)tomCatAnimationWithName:(NSString*)name withCount:(NSInteger)count
{//创建可变数组images,负责存放要播放图片数组
if ([self.tomCatView isAnimating]){
return;
}
NSMutableArray *images =[NSMutableArray array];
for (NSInteger i = 0; i < count; i++) {
//根据i来加载图片,然后添加到可变数字images里面
NSString *imageName = [NSStringstringWithFormat:@"%@_%02ld.jpg",name,i];
UIImage *image = [UIImageimageNamed:imageName];
//讲图片image添加到数组images中
[images addObject:image];
}
self.tomCatView.animationImages =images;
//设置动画时长
self.tomCatView.animationDuration =count*0.075;
//设置动画重复次数
self.tomCatView.animationDuration =1;
[self.tomCatView startAnimating];
}
- (IBAction)eataction:(UIButton *)sender {
//创建可变数组images,负责存放要播放图片数组
NSMutableArray *images =[NSMutableArray array];
for (NSInteger i = 0; i < 40; i++){
//根据i来加载图片,然后添加到可变数字images里面
NSString *imageName = [NSStringstringWithFormat:@"eat_%02ld.jpg",i];
UIImage *image = [UIImageimageNamed:imageName];
//讲图片image添加到数组images中
[images addObject:image];
}
self.tomCatView.animationImages =images;
//设置动画时长
self.tomCatView.animationDuration =40*0.075;
//设置动画重复次数
self.tomCatView.animationDuration =1;
[self.tomCatViewstartAnimating];
//开始动画
[self.tomCatViewstartAnimating];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that canbe recreated.
}
@end
网友评论