//
// RootViewController.m
// Tom
//
// Created by YIem on 15/12/11.
// Copyright (c) 2015年 www.yiem.net YIem博客. All rights reserved.
//
import "RootViewController.h"
@interface RootViewController ()
@property (nonatomic, retain)UIImageView *imgTom1;
@end
@implementation RootViewController
(void)viewDidLoad {
[super viewDidLoad]; // Do any additional setup after loading the view. self.view.backgroundColor = [UIColor whiteColor]; self.imgTom1 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width , self.view.frame.size.height)]; self.imgTom1.backgroundColor = [UIColor clearColor]; [self.view addSubview:self.imgTom1]; [_imgTom1 release]; NSString *grassPath = [[NSBundle mainBundle] pathForResource:@"angry_0" ofType:@"jpg"]; self.imgTom1.image = [UIImage imageWithContentsOfFile:grassPath]; // Tom1
//[self TOM1];
// [self TOMtu1];
// 按钮
[self an1];
[self an2];
[self an3];
[self an1_1];
[self an2_1];
[self an3_1];
// 隐藏按钮
[self anto];
[self anzhon];
[self anxiao];
[self anfootLeft];
[self anfootRight];
}
// 图标按钮123456
(void)an1
{UIButton *buttomTom1 =[UIButton buttonWithType:UIButtonTypeSystem]; buttomTom1.frame = CGRectMake(20, 400, 50, 50); [buttomTom1 setBackgroundImage:[UIImage imageNamed:@"eat.png"] forState:UIControlStateNormal]; [buttomTom1 addTarget:self action:@selector(TOMtu1) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:buttomTom1]; [buttomTom1 release];
}
(void)an2
{UIButton *buttomTom2 = [UIButton buttonWithType:UIButtonTypeSystem]; buttomTom2.frame = CGRectMake(20, 480, 50, 50); [buttomTom2 setBackgroundImage:[UIImage imageNamed:@"scratch.png"] forState:UIControlStateNormal]; [buttomTom2 addTarget:self action:@selector(TOMtu2) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:buttomTom2]; [buttomTom2 release];
}
(void)an3
{UIButton *buttomTom3 = [UIButton buttonWithType:UIButtonTypeSystem]; buttomTom3.frame = CGRectMake(20, 550, 50, 50); [buttomTom3 setBackgroundImage:[UIImage imageNamed:@"cymbal.png"] forState:UIControlStateNormal]; [buttomTom3 addTarget:self action:@selector(TOMtu3) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:buttomTom3]; [buttomTom3 release];
}
(void)an1_1
{UIButton *buttonTom1_1 = [UIButton buttonWithType:UIButtonTypeSystem]; buttonTom1_1.frame = CGRectMake(300, 400, 50, 50); [buttonTom1_1 setBackgroundImage:[UIImage imageNamed:@"fart.png"] forState:UIControlStateNormal]; [buttonTom1_1 addTarget:self action:@selector(TOMtu4) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:buttonTom1_1]; [buttonTom1_1 release];
}
(void)an2_1
{UIButton *buttonTom2_1 = [UIButton buttonWithType:UIButtonTypeSystem]; buttonTom2_1.frame = CGRectMake(300, 480, 50, 50); [buttonTom2_1 setBackgroundImage:[UIImage imageNamed:@"drink.png"] forState:UIControlStateNormal]; [buttonTom2_1 addTarget:self action:@selector(TOMtu5) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:buttonTom2_1]; [buttonTom2_1 release];
}
(void)an3_1
{UIButton *buttonTom3_1 = [UIButton buttonWithType:UIButtonTypeSystem]; buttonTom3_1.frame = CGRectMake(300, 550, 50, 50); [buttonTom3_1 setBackgroundImage:[UIImage imageNamed:@"pie.png"] forState:UIControlStateNormal]; [buttonTom3_1 addTarget:self action:@selector(TOMtu6) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:buttonTom3_1]; [buttonTom3_1 release];
}
// 隐藏按钮
(void)anto
{UIButton *anto = [UIButton buttonWithType:UIButtonTypeSystem]; anto.frame = CGRectMake(130, 200, 120, 120);
// anto.backgroundColor = [UIColor yellowColor];
[anto addTarget:self action:@selector(anTom) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:anto];
}
(void)anzhon
{UIButton *anzhon = [UIButton buttonWithType:UIButtonTypeSystem]; anzhon.frame = CGRectMake(140, 400, 100, 100);
// anzhon.backgroundColor = [UIColor yellowColor];
[anzhon addTarget:self action:@selector(anZhon) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:anzhon];
}
(void)anxiao
{UIButton *anxiao = [UIButton buttonWithType:UIButtonTypeSystem]; anxiao.frame = CGRectMake(160, 550, 50, 50);
// anxiao.backgroundColor = [UIColor yellowColor];
[anxiao addTarget:self action:@selector(anXiao) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:anxiao];
}
- (void)anfootLeft
{
UIButton *anfootLeft = [UIButton buttonWithType:UIButtonTypeSystem];
anfootLeft.frame = CGRectMake(140, 610, 35, 35);
// anfootLeft.backgroundColor = [UIColor yellowColor];
[anfootLeft addTarget:self action:@selector(anright) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:anfootLeft];
}
(void)anfootRight
{UIButton *anfootright = [UIButton buttonWithType:UIButtonTypeSystem]; anfootright.frame = CGRectMake(200, 610, 35, 35);
// anfootright.backgroundColor = [UIColor yellowColor];
[anfootright addTarget:self action:@selector(anlift) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:anfootright];
}
// TOM 动画
(void)TOM1
{
// 播放
self.imgTom1 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 20, self.view.frame.size.width, self.view.frame.size.height)];
//self.imgTom1.backgroundColor = [UIColor clearColor];
self.imgTom1.image = [UIImage imageNamed:@"angry_0.jpg"];
[self.view addSubview:self.imgTom1];
[_imgTom1 release];NSMutableArray *imgTomArr1 = [NSMutableArray array];
for (NSInteger i = 0; i < 26; i++) {NSString *nameTom1 = [NSString stringWithFormat:@"angry_%ld", i]; NSString *pathTom1 = [[NSBundle mainBundle]pathForResource:nameTom1 ofType:@"jpg"]; UIImage *imgTom1 = [UIImage imageWithContentsOfFile:pathTom1]; [imgTomArr1 addObject:imgTom1];
}
self.imgTom1.animationDuration = 4;
self.imgTom1.animationImages = imgTomArr1;
self.imgTom1.animationRepeatCount = 1;
[self.imgTom1 startAnimating];}
- (void)TOMtu1
{
// self.imgTom1 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 20, self.view.frame.size.width, self.view.frame.size.height)];
// self.imgTom1.image = [UIImage imageNamed:@"eat_0.jpg"];
// [self.view addSubview:self.imgTom1];
// [_imgTom1 release];
NSMutableArray *imgTomArr1 = [NSMutableArray array];
for (NSInteger i = 0; i < 39; i++) {
// NSString *nameTom = [NSString stringWithFormat:@"eat_%ld", i];
// NSString *pathTom = [[NSBundle mainBundle]pathForResource:nameTom ofType:@"jpg"];
// UIImage *imgTom = [UIImage imageWithContentsOfFile:pathTom];
// [imgTomArr1 addObject:imgTom];
[imgTomArr1 addObject:[UIImage imageNamed:[NSString stringWithFormat:@"eat_%ld.jpg",i]]];
}
self.imgTom1.animationDuration = 4;
self.imgTom1.animationImages = imgTomArr1;
self.imgTom1.animationRepeatCount = 1;
[self.imgTom1 startAnimating];
}
(void)TOMtu2
{
NSMutableArray *imgTomArr2_2 = [NSMutableArray array];
for (NSInteger i = 0; i < 55; i++) {[imgTomArr2_2 addObject:[UIImage imageNamed:[NSString stringWithFormat:@"scratch_%ld.jpg", i]]];
}
self.imgTom1.animationDuration = 5;
self.imgTom1.animationImages = imgTomArr2_2;
self.imgTom1.animationRepeatCount = 1;
[self.imgTom1 startAnimating];
}(void)TOMtu3
{
NSMutableArray *imgTomArr2 = [NSMutableArray array];
for (NSInteger i = 0; i < 12; i++) {[imgTomArr2 addObject:[UIImage imageNamed:[NSString stringWithFormat:@"cymbal_%ld.jpg", i]]];
}
self.imgTom1.animationDuration = 1;
self.imgTom1.animationImages = imgTomArr2;
self.imgTom1.animationRepeatCount = 1;
[self.imgTom1 startAnimating];
}(void)TOMtu4
{
NSMutableArray *imgTomArr4 = [NSMutableArray array];
for (NSInteger i = 0; i < 27; i++) {[imgTomArr4 addObject:[UIImage imageNamed:[NSString stringWithFormat:@"fart_%ld.jpg",i]]];
}
self.imgTom1.animationDuration = 3;
self.imgTom1.animationImages = imgTomArr4;
self.imgTom1.animationRepeatCount = 1;
[self.imgTom1 startAnimating];
}(void)TOMtu5
{
NSMutableArray *imgTomArr2 = [NSMutableArray array];
for (NSInteger i = 0; i < 80; i++) {[imgTomArr2 addObject:[UIImage imageNamed:[NSString stringWithFormat:@"drink_%ld.jpg",i]]];
}
self.imgTom1.animationDuration = 6;
self.imgTom1.animationImages = imgTomArr2
;
self.imgTom1.animationRepeatCount = 1;
[self.imgTom1 startAnimating];
}(void)TOMtu6
{
NSMutableArray *imgTomArr6 = [NSMutableArray array];
for (NSInteger i = 0; i < 23; i++) {[imgTomArr6 addObject:[UIImage imageNamed:[NSString stringWithFormat:@"pie_%ld.jpg", i]]];
}
self.imgTom1.animationDuration = 1;
self.imgTom1.animationImages = imgTomArr6;
self.imgTom1.animationRepeatCount = 1;
[self.imgTom1 startAnimating];
}
// 隐藏点击动画
(void)anTom
{
NSMutableArray *imgTom = [NSMutableArray array];
for (NSInteger i = 0; i < 80; i ++) {[imgTom addObject:[UIImage imageNamed:[NSString stringWithFormat:@"knockout_%ld.jpg", i]]];
}
self.imgTom1.animationDuration = 5;
self.imgTom1.animationImages = imgTom;
self.imgTom1.animationRepeatCount = 1;
[self.imgTom1 startAnimating];}
(void)anZhon
{
NSMutableArray *imgTom = [NSMutableArray array];
for (NSInteger i = 0; i < 33; i++) {[imgTom addObject:[UIImage imageNamed:[NSString stringWithFormat:@"stomach_%ld.jpg",i]]];
}
self.imgTom1.animationDuration = 3;
self.imgTom1.animationImages = imgTom;
self.imgTom1.animationRepeatCount = 1;
[self.imgTom1 startAnimating];
}(void)anXiao
{
NSMutableArray *imgTom = [NSMutableArray array];
for (NSInteger i = 0; i < 33; i++) {[imgTom addObject:[UIImage imageNamed:[NSString stringWithFormat:@"stomach_%ld.jpg", i]]];
}
self.imgTom1.animationDuration = 2;
self.imgTom1.animationImages = imgTom;
self.imgTom1.animationRepeatCount = 1;
[self.imgTom1 startAnimating];
}(void)anlift
{
NSMutableArray *imgTom = [NSMutableArray array];
for (NSInteger i = 0; i < 29; i++) {[imgTom addObject:[UIImage imageNamed:[NSString stringWithFormat:@"footLeft_%ld.jpg",i]]];
}
self.imgTom1.animationDuration = 2;
self.imgTom1.animationImages = imgTom;
self.imgTom1.animationRepeatCount = 1;
[self.imgTom1 startAnimating];
}(void)anright
{
NSMutableArray *imgTom = [NSMutableArray array];
for (NSInteger i = 0; i < 29; i++) {[imgTom addObject:[UIImage imageNamed:[NSString stringWithFormat:@"footRight_%ld.jpg", i]]];
}
self.imgTom1.animationDuration = 3;
self.imgTom1.animationImages = imgTom;
self.imgTom1.animationRepeatCount = 1;
[self.imgTom1 startAnimating];
}- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller.
}
*/
@end