//
//? 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];
//序列幀動畫要播放的圖片數(shù)組
//imageView.animationImages
//動畫時長
//imageView.animationDuration
//動畫重復(fù)次數(shù)
//imageView.animationRepeatCount
//開始動畫
//[imageView startAnimating];
//結(jié)束動畫
//[imageView stopAnimating];
//是否正在執(zhí)行動畫
//[imageView isAnimating];
}
- (IBAction)FootLeftAction:(UIButton *)sender {
//湯姆貓根據(jù)名字和數(shù)量執(zhí)行動畫
[self tomCatAnimationWithName:@"FootLeft" WithCount:30];
/*
//創(chuàng)建可變數(shù)組images,負(fù)責(zé)存放要播放的圖片數(shù)組
NSMutableArray *images = [NSMutableArray array];
for (NSInteger i = 0;i < 30;i++) {
//根據(jù)i來加載圖片嘱巾,然后添加到可變數(shù)組images里面
NSString *imageName = [NSString stringWithFormat:@"FootLeft_%02ld.jpg",i];
//根據(jù)格式化的圖片名加載圖片image
UIImage *image = [UIImage imageNamed:imageName];
//將圖片image添加到數(shù)組images中
[images addObject:image];
}
//設(shè)置動畫圖片數(shù)組
self.tomCatView.animationImages = images;
//設(shè)置動畫時長
self.tomCatView.animationDuration = 30*0.075;
//設(shè)置動畫重復(fù)次數(shù)
self.tomCatView.animationRepeatCount = 1;
//開始動畫
[self.tomCatView startAnimating];
*/
}
- (IBAction)footRightAction:(UIButton *)sender {
//湯姆貓根據(jù)名字和數(shù)量執(zhí)行動畫
[self tomCatAnimationWithName:@"footRight" WithCount:30];
/* //創(chuàng)建可變數(shù)組images,負(fù)責(zé)存放要播放的圖片數(shù)組
NSMutableArray *images = [NSMutableArray array];
for (NSInteger i = 0;i < 30;i++) {
//根據(jù)i來加載圖片筒愚,然后添加到可變數(shù)組images里面
NSString *imageName = [NSString stringWithFormat:@"footRight_%02ld.jpg",i];
//根據(jù)格式化的圖片名加載圖片image
UIImage *image = [UIImage imageNamed:imageName];
//將圖片image添加到數(shù)組images中
[images addObject:image];
}
//設(shè)置動畫圖片數(shù)組
self.tomCatView.animationImages = images;
//設(shè)置動畫時長
self.tomCatView.animationDuration = 30*0.075;
//設(shè)置動畫重復(fù)次數(shù)
self.tomCatView.animationRepeatCount = 1;
//開始動畫
[self.tomCatView startAnimating];
*/
}
- (IBAction)eatBirdAction:(UIButton *)sender {
//湯姆貓根據(jù)名字和數(shù)量執(zhí)行動畫
[self tomCatAnimationWithName:@"eat" WithCount:40];
/*
//創(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];
//根據(jù)格式化的圖片名加載圖片image
UIImage *image = [UIImage imageNamed:imageName];
//將圖片image添加到數(shù)組images中
[images addObject:image];
}
//設(shè)置動畫圖片數(shù)組
self.tomCatView.animationImages = images;
//設(shè)置動畫時長
self.tomCatView.animationDuration = 40*0.075;
//設(shè)置動畫重復(fù)次數(shù)
self.tomCatView.animationRepeatCount = 1;
//開始動畫
[self.tomCatView startAnimating];
*/
}
-(void)tomCatAnimationWithName:(NSString*)name WithCount:(NSInteger)count;
{
//判斷是否正在執(zhí)行
if([self.tomCatView isAnimating]){
return;
}
//創(chuàng)建可變數(shù)組images,負(fù)責(zé)存放要播放的圖片數(shù)組
NSMutableArray *images = [NSMutableArray array];
//借助i循環(huán)創(chuàng)建圖片
for (NSInteger i = 0;i < count;i++) {
//將name拼接
NSString *imageName = [NSString stringWithFormat:@"%@_%02ld.jpg",name,i];
//根據(jù)格式化的圖片名加載圖片image
UIImage *image = [UIImage imageNamed:imageName];
//將圖片image添加到數(shù)組images中
[images addObject:image];
}
//設(shè)置動畫圖片數(shù)組
self.tomCatView.animationImages = images;
//設(shè)置動畫時長
self.tomCatView.animationDuration = count*0.075;
//設(shè)置動畫重復(fù)次數(shù)
self.tomCatView.animationRepeatCount = 1;
//開始動畫
[self.tomCatView startAnimating];
}
- (IBAction)pieAction:(UIButton *)sender {
//湯姆貓根據(jù)名字和數(shù)量執(zhí)行動畫
[self tomCatAnimationWithName:@"pie" WithCount:24];
/*
//創(chuàng)建可變數(shù)組images,負(fù)責(zé)存放要播放的圖片數(shù)組
NSMutableArray *images = [NSMutableArray array];
for (NSInteger i = 0;i < 24;i++) {
//根據(jù)i來加載圖片探膊,然后添加到可變數(shù)組images里面
NSString *imageName = [NSString stringWithFormat:@"pie_%02ld.jpg",i];
//根據(jù)格式化的圖片名加載圖片image
UIImage *image = [UIImage imageNamed:imageName];
//將圖片image添加到數(shù)組images中
[images addObject:image];
}
//設(shè)置動畫圖片數(shù)組
self.tomCatView.animationImages = images;
//設(shè)置動畫時長
self.tomCatView.animationDuration = 24*0.075;
//設(shè)置動畫重復(fù)次數(shù)
self.tomCatView.animationRepeatCount = 1;
//開始動畫
[self.tomCatView startAnimating];
*/
}
- (IBAction)stomachAction:(UIButton *)sender {
//湯姆貓根據(jù)名字和數(shù)量執(zhí)行動畫
[self tomCatAnimationWithName:@"stomach" WithCount:34];
/*
//創(chuàng)建可變數(shù)組images,負(fù)責(zé)存放要播放的圖片數(shù)組
NSMutableArray *images = [NSMutableArray array];
for (NSInteger i = 0;i < 34;i++) {
//根據(jù)i來加載圖片赋秀,然后添加到可變數(shù)組images里面
NSString *imageName = [NSString stringWithFormat:@"stomach_%02ld.jpg",i];
//根據(jù)格式化的圖片名加載圖片image
UIImage *image = [UIImage imageNamed:imageName];
//將圖片image添加到數(shù)組images中
[images addObject:image];
}
//設(shè)置動畫圖片數(shù)組
self.tomCatView.animationImages = images;
//設(shè)置動畫時長
self.tomCatView.animationDuration = 34*0.075;
//設(shè)置動畫重復(fù)次數(shù)
self.tomCatView.animationRepeatCount = 1;
//開始動畫
[self.tomCatView startAnimating];
*/
}
- (IBAction)knockoutAction:(UIButton *)sender {
//湯姆貓根據(jù)名字和數(shù)量執(zhí)行動畫
[self tomCatAnimationWithName:@"knockout" WithCount:81];
/*
//創(chuàng)建可變數(shù)組images,負(fù)責(zé)存放要播放的圖片數(shù)組
NSMutableArray *images = [NSMutableArray array];
for (NSInteger i = 0;i < 81;i++) {
//根據(jù)i來加載圖片利朵,然后添加到可變數(shù)組images里面
NSString *imageName = [NSString stringWithFormat:@"knockout_%02ld.jpg",i];
//根據(jù)格式化的圖片名加載圖片image
UIImage *image = [UIImage imageNamed:imageName];
//將圖片image添加到數(shù)組images中
[images addObject:image];
}
//設(shè)置動畫圖片數(shù)組
self.tomCatView.animationImages = images;
//設(shè)置動畫時長
self.tomCatView.animationDuration = 81*0.075;
//設(shè)置動畫重復(fù)次數(shù)
self.tomCatView.animationRepeatCount = 1;
//開始動畫
[self.tomCatView startAnimating];
*/
}
- (IBAction)angryAction:(UIButton *)sender {
//湯姆貓根據(jù)名字和數(shù)量執(zhí)行動畫
[self tomCatAnimationWithName:@"angry" WithCount:26];
/*
//創(chuàng)建可變數(shù)組images,負(fù)責(zé)存放要播放的圖片數(shù)組
NSMutableArray *images = [NSMutableArray array];
for (NSInteger i = 0;i < 26;i++) {
//根據(jù)i來加載圖片,然后添加到可變數(shù)組images里面
NSString *imageName = [NSString stringWithFormat:@"angry_%02ld.jpg",i];
//根據(jù)格式化的圖片名加載圖片image
UIImage *image = [UIImage imageNamed:imageName];
//將圖片image添加到數(shù)組images中
[images addObject:image];
}
//設(shè)置動畫圖片數(shù)組
self.tomCatView.animationImages = images;
//設(shè)置動畫時長
self.tomCatView.animationDuration = 26*0.075;
//設(shè)置動畫重復(fù)次數(shù)
self.tomCatView.animationRepeatCount = 1;
//開始動畫
[self.tomCatView startAnimating];
*/
}
- (IBAction)scratchAction:(UIButton *)sender {
//湯姆貓根據(jù)名字和數(shù)量執(zhí)行動畫
[self tomCatAnimationWithName:@"scratch" WithCount:56];
/*
//創(chuàng)建可變數(shù)組images,負(fù)責(zé)存放要播放的圖片數(shù)組
NSMutableArray *images = [NSMutableArray array];
for (NSInteger i = 0;i < 56;i++) {
//根據(jù)i來加載圖片猎莲,然后添加到可變數(shù)組images里面
NSString *imageName = [NSString stringWithFormat:@"scratch_%02ld.jpg",i];
//根據(jù)格式化的圖片名加載圖片image
UIImage *image = [UIImage imageNamed:imageName];
//將圖片image添加到數(shù)組images中
[images addObject:image];
}
//設(shè)置動畫圖片數(shù)組
self.tomCatView.animationImages = images;
//設(shè)置動畫時長
self.tomCatView.animationDuration = 56*0.075;
//設(shè)置動畫重復(fù)次數(shù)
self.tomCatView.animationRepeatCount = 1;
//開始動畫
[self.tomCatView startAnimating];
*/
}
- (IBAction)cymbalAction:(UIButton *)sender {
//湯姆貓根據(jù)名字和數(shù)量執(zhí)行動畫
[self tomCatAnimationWithName:@"cymbal" WithCount:13];
/*
//創(chuàng)建可變數(shù)組images,負(fù)責(zé)存放要播放的圖片數(shù)組
NSMutableArray *images = [NSMutableArray array];
for (NSInteger i = 0;i < 13;i++) {
//根據(jù)i來加載圖片绍弟,然后添加到可變數(shù)組images里面
NSString *imageName = [NSString stringWithFormat:@"cymbal_%02ld.jpg",i];
//根據(jù)格式化的圖片名加載圖片image
UIImage *image = [UIImage imageNamed:imageName];
//將圖片image添加到數(shù)組images中
[images addObject:image];
}
//設(shè)置動畫圖片數(shù)組
self.tomCatView.animationImages = images;
//設(shè)置動畫時長
self.tomCatView.animationDuration = 13*0.075;
//設(shè)置動畫重復(fù)次數(shù)
self.tomCatView.animationRepeatCount = 1;
//開始動畫
[self.tomCatView startAnimating];
*/
}
- (IBAction)fartAction:(UIButton *)sender {
//湯姆貓根據(jù)名字和數(shù)量執(zhí)行動畫
[self tomCatAnimationWithName:@"fart" WithCount:28];
/*
//創(chuàng)建可變數(shù)組images,負(fù)責(zé)存放要播放的圖片數(shù)組
NSMutableArray *images = [NSMutableArray array];
for (NSInteger i = 0;i < 28;i++) {
//根據(jù)i來加載圖片,然后添加到可變數(shù)組images里面
NSString *imageName = [NSString stringWithFormat:@"fart_%02ld.jpg",i];
//根據(jù)格式化的圖片名加載圖片image
UIImage *image = [UIImage imageNamed:imageName];
//將圖片image添加到數(shù)組images中
[images addObject:image];
}
//設(shè)置動畫圖片數(shù)組
self.tomCatView.animationImages = images;
//設(shè)置動畫時長
self.tomCatView.animationDuration = 28*0.075;
//設(shè)置動畫重復(fù)次數(shù)
self.tomCatView.animationRepeatCount = 1;
//開始動畫
[self.tomCatView startAnimating];
*/
}
- (IBAction)drinkMilkAction:(UIButton *)sender {
//湯姆貓根據(jù)名字和數(shù)量執(zhí)行動畫
[self tomCatAnimationWithName:@"drink" WithCount:81];
/*
//創(chuàng)建可變數(shù)組images,負(fù)責(zé)存放要播放的圖片數(shù)組
NSMutableArray *images = [NSMutableArray array];
for (NSInteger i = 0;i < 81;i++) {
//根據(jù)i來加載圖片著洼,然后添加到可變數(shù)組images里面
NSString *imageName = [NSString stringWithFormat:@"drink_%02ld.jpg",i];
//根據(jù)格式化的圖片名加載圖片image
UIImage *image = [UIImage imageNamed:imageName];
//將圖片image添加到數(shù)組images中
[images addObject:image];
}
//設(shè)置動畫圖片數(shù)組
self.tomCatView.animationImages = images;
//設(shè)置動畫時長
self.tomCatView.animationDuration = 81*0.075;
//設(shè)置動畫重復(fù)次數(shù)
self.tomCatView.animationRepeatCount = 1;
//開始動畫
[self.tomCatView startAnimating];
*/
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end