会说话的tom猫
来源:互联网 发布:信永中和最新工资算法 编辑:程序博客网 时间:2024/04/28 08:07
这是一个很好玩的软件 看起来实现比较复杂
但事实上,这个软件并不是那么复杂,代码量很少,但是思想很重要
一款软件存活关键在与他所体现的价值,和它的创新性
用到的技术很简单 就是图片播放加上动画效果,这里注释了的代码是封装之后的代码
#import "ViewController.h"@interface ViewController ()- (IBAction)knock;- (IBAction)drink;- (IBAction)rightFoot;@property (weak, nonatomic) IBOutlet UIImageView *tom;@end@implementation ViewController- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib.}- (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.}-(void)runAnimationWithCount:(int)count andFileName:(NSString *)name{ if (self.tom.isAnimating) return; NSMutableArray *imageArray = [[NSMutableArray alloc]init]; for (int i = 0; i <= count; i++) { //imageName 有缓存(传入文件名) NSString *fileName = [NSString stringWithFormat:@"%@_%02d.jpg",name,i]; //UIImage *image = [UIImage imageNamed:fileName]; NSBundle *bundle = [NSBundle mainBundle]; NSString *path = [bundle pathForResource:fileName ofType:nil]; UIImage *image = [UIImage imageWithContentsOfFile:path]; [imageArray addObject:image]; } self.tom.animationImages = imageArray; self.tom.animationRepeatCount = 1; self.tom.animationDuration = imageArray.count*0.1; [self.tom startAnimating]; //动画放完1秒后清空内存 CGFloat delay = self.tom.animationDuration +1.0; //[self performSelector:@selector(clearCache) withObject:nil afterDelay:delay]; [self.tom performSelector:@selector(setAnimationImages:) withObject:nil afterDelay:delay]; }//-(void)clearCache//{// NSLog(@"++++++clearCache");// self.tom.animationImages = nil;// [self.tom setAnimationImages:nil];//}- (IBAction)knock { [self runAnimationWithCount:80 andFileName:@"knockout"]; /* if (self.tom.isAnimating) return; NSMutableArray *imageArray = [[NSMutableArray alloc]init]; for (int i = 0; i <= 80; i++) { NSString *fileName = [NSString stringWithFormat:@"knockout_%02d.jpg",i]; UIImage *image = [UIImage imageNamed:fileName]; [imageArray addObject:image]; } self.tom.animationImages = imageArray; self.tom.animationRepeatCount = 1; self.tom.animationDuration = imageArray.count*0.1; [self.tom startAnimating]; */}- (IBAction)drink { [self runAnimationWithCount:80 andFileName:@"drink"];// if (self.tom.isAnimating)// return;// NSMutableArray *imageArray = [[NSMutableArray alloc]init];;// for (int i = 0; i<=80; i++) {// // //计算文件名// NSString *fileName = [NSString stringWithFormat:@"drink_%02d.jpg",i];// //加载图片// UIImage *image = [UIImage imageNamed:fileName];// //添加图片到数组// [imageArray addObject:image];// }// // self.tom.animationImages = imageArray;// //设置播放次数// self.tom.animationRepeatCount = 1;// //设置时间// self.tom.animationDuration = imageArray.count*0.1;// [self.tom startAnimating]; }- (IBAction)rightFoot { [self runAnimationWithCount:29 andFileName:@"footRight"];// // if (self.tom.isAnimating)// return;// NSMutableArray *imageArray = [[NSMutableArray alloc]init];;// for (int i = 0; i<=29; i++) {// // //计算文件名// NSString *fileName = [NSString stringWithFormat:@"footRight_%02d.jpg",i];// //加载图片// UIImage *image = [UIImage imageNamed:fileName];// //添加图片到数组// [imageArray addObject:image];// }// // self.tom.animationImages = imageArray;// //设置播放次数// self.tom.animationRepeatCount = 1;// //设置时间// self.tom.animationDuration = imageArray.count*0.1;// [self.tom startAnimating];}@end
0 0
- 会说话的tom猫
- 会说话的哑巴
- “会“说话的人~
- 会说话的简历 TalkingCV
- 会说话的简历 TalkingCV
- 会说话的简历 TalkingCV
- 会说话的简历 TalkingCV
- 会说话的QQ竞拍
- 会说话
- 会说话
- tom猫的UI
- 魔术会说话的王牌的原理
- 让你的键盘会说话!
- 让你的程序会说话
- 让你的键盘会说话!
- “会说话的ipod”MP3播放器
- 拥有一个会说话的青蛙
- 世界上最会说话的人
- 找出二叉树中某两个结点的第一个公共祖先
- poj1080
- opencv学习(七)(opencv3.0.0+VS2012+win7)打开摄像头并且进行边缘检测加上了滑动条
- python二进制处理详述
- Java之旅hibernate(1)——初始
- 会说话的tom猫
- [CQOI2013]新Nim游戏
- c++ stl 2
- SDUT2015暑假集训14级周赛4
- intent过滤器相关选项
- 黑马程序员10java高新技术
- php var_export与var_dump的区别
- (HTML部分)特供.Net基础全套视频教程2014版(第十八天)(更新于2015年10月24日02:23:36)
- 关于产品经理的学习