//
// ViewController.m
// 汤姆猫
//
// Created by lanou on 16/7/12.
// Copyright © 2016年 lanou. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *tomCatView;
@end
@implementation ViewController
/*
*/
- (void)viewDidLoad {
[super viewDidLoad];
//新建类的方法名
//UIImageView *imageView = [UIImageView new];
//序列帧动画要播放的图片数组
//imageView.animationImages
//动画时长
//imageView.animationDuration
//动画重复次数
//imageView.animationRepeatCount
//开始动画
//[imageView startAnimating];
//结束动画
//[imageView stopAnimating];
//是否正在执行动画
//[imageView isAnimating];
}
- (IBAction)FootLeftAction:(UIButton *)sender {
//汤姆猫根据名字和数量执行动画
[self tomCatAnimationWithName:@"FootLeft" WithCount:30];
/*
//创建可变数组images,负责存放要播放的图片数组
NSMutableArray *images = [NSMutableArray array];
for (NSInteger i = 0;i < 30;i++) {
//根据i来加载图片,然后添加到可变数组images里面
NSString *imageName = [NSString stringWithFormat:@"FootLeft_%02ld.jpg",i];
//根据格式化的图片名加载图片image
UIImage *image = [UIImage imageNamed:imageName];
//将图片image添加到数组images中
[images addObject:image];
}
//设置动画图片数组
self.tomCatView.animationImages = images;
//设置动画时长
self.tomCatView.animationDuration = 30*0.075;
//设置动画重复次数
self.tomCatView.animationRepeatCount = 1;
//开始动画
[self.tomCatView startAnimating];
*/
}
- (IBAction)footRightAction:(UIButton *)sender {
//汤姆猫根据名字和数量执行动画
[self tomCatAnimationWithName:@"footRight" WithCount:30];
/* //创建可变数组images,负责存放要播放的图片数组
NSMutableArray *images = [NSMutableArray array];
for (NSInteger i = 0;i < 30;i++) {
//根据i来加载图片,然后添加到可变数组images里面
NSString *imageName = [NSString stringWithFormat:@"footRight_%02ld.jpg",i];
//根据格式化的图片名加载图片image
UIImage *image = [UIImage imageNamed:imageName];
//将图片image添加到数组images中
[images addObject:image];
}
//设置动画图片数组
self.tomCatView.animationImages = images;
//设置动画时长
self.tomCatView.animationDuration = 30*0.075;
//设置动画重复次数
self.tomCatView.animationRepeatCount = 1;
//开始动画
[self.tomCatView startAnimating];
*/
}
- (IBAction)eatBirdAction:(UIButton *)sender {
//汤姆猫根据名字和数量执行动画
[self tomCatAnimationWithName:@"eat" WithCount:40];
/*
//创建可变数组images,负责存放要播放的图片数组
NSMutableArray *images = [NSMutableArray array];
for (NSInteger i = 0;i < 40;i++) {
//根据i来加载图片,然后添加到可变数组images里面
NSString *imageName = [NSString stringWithFormat:@"eat_%02ld.jpg",i];
//根据格式化的图片名加载图片image
UIImage *image = [UIImage imageNamed:imageName];
//将图片image添加到数组images中
[images addObject:image];
}
//设置动画图片数组
self.tomCatView.animationImages = images;
//设置动画时长
self.tomCatView.animationDuration = 40*0.075;
//设置动画重复次数
self.tomCatView.animationRepeatCount = 1;
//开始动画
[self.tomCatView startAnimating];
*/
}
-(void)tomCatAnimationWithName:(NSString*)name WithCount:(NSInteger)count;
{
//判断是否正在执行
if([self.tomCatView isAnimating]){
return;
}
//创建可变数组images,负责存放要播放的图片数组
NSMutableArray *images = [NSMutableArray array];
//借助i循环创建图片
for (NSInteger i = 0;i < count;i++) {
//将name拼接
NSString *imageName = [NSString stringWithFormat:@"%@_%02ld.jpg",name,i];
//根据格式化的图片名加载图片image
UIImage *image = [UIImage imageNamed:imageName];
//将图片image添加到数组images中
[images addObject:image];
}
//设置动画图片数组
self.tomCatView.animationImages = images;
//设置动画时长
self.tomCatView.animationDuration = count*0.075;
//设置动画重复次数
self.tomCatView.animationRepeatCount = 1;
//开始动画
[self.tomCatView startAnimating];
}
- (IBAction)pieAction:(UIButton *)sender {
//汤姆猫根据名字和数量执行动画
[self tomCatAnimationWithName:@"pie" WithCount:24];
/*
//创建可变数组images,负责存放要播放的图片数组
NSMutableArray *images = [NSMutableArray array];
for (NSInteger i = 0;i < 24;i++) {
//根据i来加载图片,然后添加到可变数组images里面
NSString *imageName = [NSString stringWithFormat:@"pie_%02ld.jpg",i];
//根据格式化的图片名加载图片image
UIImage *image = [UIImage imageNamed:imageName];
//将图片image添加到数组images中
[images addObject:image];
}
//设置动画图片数组
self.tomCatView.animationImages = images;
//设置动画时长
self.tomCatView.animationDuration = 24*0.075;
//设置动画重复次数
self.tomCatView.animationRepeatCount = 1;
//开始动画
[self.tomCatView startAnimating];
*/
}
- (IBAction)stomachAction:(UIButton *)sender {
//汤姆猫根据名字和数量执行动画
[self tomCatAnimationWithName:@"stomach" WithCount:34];
/*
//创建可变数组images,负责存放要播放的图片数组
NSMutableArray *images = [NSMutableArray array];
for (NSInteger i = 0;i < 34;i++) {
//根据i来加载图片,然后添加到可变数组images里面
NSString *imageName = [NSString stringWithFormat:@"stomach_%02ld.jpg",i];
//根据格式化的图片名加载图片image
UIImage *image = [UIImage imageNamed:imageName];
//将图片image添加到数组images中
[images addObject:image];
}
//设置动画图片数组
self.tomCatView.animationImages = images;
//设置动画时长
self.tomCatView.animationDuration = 34*0.075;
//设置动画重复次数
self.tomCatView.animationRepeatCount = 1;
//开始动画
[self.tomCatView startAnimating];
*/
}
- (IBAction)knockoutAction:(UIButton *)sender {
//汤姆猫根据名字和数量执行动画
[self tomCatAnimationWithName:@"knockout" WithCount:81];
/*
//创建可变数组images,负责存放要播放的图片数组
NSMutableArray *images = [NSMutableArray array];
for (NSInteger i = 0;i < 81;i++) {
//根据i来加载图片,然后添加到可变数组images里面
NSString *imageName = [NSString stringWithFormat:@"knockout_%02ld.jpg",i];
//根据格式化的图片名加载图片image
UIImage *image = [UIImage imageNamed:imageName];
//将图片image添加到数组images中
[images addObject:image];
}
//设置动画图片数组
self.tomCatView.animationImages = images;
//设置动画时长
self.tomCatView.animationDuration = 81*0.075;
//设置动画重复次数
self.tomCatView.animationRepeatCount = 1;
//开始动画
[self.tomCatView startAnimating];
*/
}
- (IBAction)angryAction:(UIButton *)sender {
//汤姆猫根据名字和数量执行动画
[self tomCatAnimationWithName:@"angry" WithCount:26];
/*
//创建可变数组images,负责存放要播放的图片数组
NSMutableArray *images = [NSMutableArray array];
for (NSInteger i = 0;i < 26;i++) {
//根据i来加载图片,然后添加到可变数组images里面
NSString *imageName = [NSString stringWithFormat:@"angry_%02ld.jpg",i];
//根据格式化的图片名加载图片image
UIImage *image = [UIImage imageNamed:imageName];
//将图片image添加到数组images中
[images addObject:image];
}
//设置动画图片数组
self.tomCatView.animationImages = images;
//设置动画时长
self.tomCatView.animationDuration = 26*0.075;
//设置动画重复次数
self.tomCatView.animationRepeatCount = 1;
//开始动画
[self.tomCatView startAnimating];
*/
}
- (IBAction)scratchAction:(UIButton *)sender {
//汤姆猫根据名字和数量执行动画
[self tomCatAnimationWithName:@"scratch" WithCount:56];
/*
//创建可变数组images,负责存放要播放的图片数组
NSMutableArray *images = [NSMutableArray array];
for (NSInteger i = 0;i < 56;i++) {
//根据i来加载图片,然后添加到可变数组images里面
NSString *imageName = [NSString stringWithFormat:@"scratch_%02ld.jpg",i];
//根据格式化的图片名加载图片image
UIImage *image = [UIImage imageNamed:imageName];
//将图片image添加到数组images中
[images addObject:image];
}
//设置动画图片数组
self.tomCatView.animationImages = images;
//设置动画时长
self.tomCatView.animationDuration = 56*0.075;
//设置动画重复次数
self.tomCatView.animationRepeatCount = 1;
//开始动画
[self.tomCatView startAnimating];
*/
}
- (IBAction)cymbalAction:(UIButton *)sender {
//汤姆猫根据名字和数量执行动画
[self tomCatAnimationWithName:@"cymbal" WithCount:13];
/*
//创建可变数组images,负责存放要播放的图片数组
NSMutableArray *images = [NSMutableArray array];
for (NSInteger i = 0;i < 13;i++) {
//根据i来加载图片,然后添加到可变数组images里面
NSString *imageName = [NSString stringWithFormat:@"cymbal_%02ld.jpg",i];
//根据格式化的图片名加载图片image
UIImage *image = [UIImage imageNamed:imageName];
//将图片image添加到数组images中
[images addObject:image];
}
//设置动画图片数组
self.tomCatView.animationImages = images;
//设置动画时长
self.tomCatView.animationDuration = 13*0.075;
//设置动画重复次数
self.tomCatView.animationRepeatCount = 1;
//开始动画
[self.tomCatView startAnimating];
*/
}
- (IBAction)fartAction:(UIButton *)sender {
//汤姆猫根据名字和数量执行动画
[self tomCatAnimationWithName:@"fart" WithCount:28];
/*
//创建可变数组images,负责存放要播放的图片数组
NSMutableArray *images = [NSMutableArray array];
for (NSInteger i = 0;i < 28;i++) {
//根据i来加载图片,然后添加到可变数组images里面
NSString *imageName = [NSString stringWithFormat:@"fart_%02ld.jpg",i];
//根据格式化的图片名加载图片image
UIImage *image = [UIImage imageNamed:imageName];
//将图片image添加到数组images中
[images addObject:image];
}
//设置动画图片数组
self.tomCatView.animationImages = images;
//设置动画时长
self.tomCatView.animationDuration = 28*0.075;
//设置动画重复次数
self.tomCatView.animationRepeatCount = 1;
//开始动画
[self.tomCatView startAnimating];
*/
}
- (IBAction)drinkMilkAction:(UIButton *)sender {
//汤姆猫根据名字和数量执行动画
[self tomCatAnimationWithName:@"drink" WithCount:81];
/*
//创建可变数组images,负责存放要播放的图片数组
NSMutableArray *images = [NSMutableArray array];
for (NSInteger i = 0;i < 81;i++) {
//根据i来加载图片,然后添加到可变数组images里面
NSString *imageName = [NSString stringWithFormat:@"drink_%02ld.jpg",i];
//根据格式化的图片名加载图片image
UIImage *image = [UIImage imageNamed:imageName];
//将图片image添加到数组images中
[images addObject:image];
}
//设置动画图片数组
self.tomCatView.animationImages = images;
//设置动画时长
self.tomCatView.animationDuration = 81*0.075;
//设置动画重复次数
self.tomCatView.animationRepeatCount = 1;
//开始动画
[self.tomCatView startAnimating];
*/
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end