iOS-植物大战僵尸-UIVIew-UIImageView-

iOS-植物大战僵尸-UIVIew-UIImageView-
屏幕快照 2016-01-14 上午8.53.43.png

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

  • (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    self.view.backgroundColor = [UIColor whiteColor];
    // YIem
    // 僵尸
    // 僵尸界面背景
    UIImageView *bjing = [[UIImageView alloc]initWithFrame:self.view.frame];
    bjing.image = [UIImage imageNamed:@"BackGround"];
    [self.view addSubview:bjing];
    [bjing release];

    // 植物
    // 向日葵
    UIImageView *image1 = [[UIImageView alloc] initWithFrame:CGRectMake(60, 90, 100, 100)];
    NSMutableArray *image1Arr = [NSMutableArray array];
    for (NSInteger i = 0; i < 18; i++) {
    NSString *imageName = [NSString stringWithFormat:@"flower%ld.tiff", i + 1];
    UIImage *image = [UIImage imageNamed:imageName];
    [image1Arr addObject:image];
    }
    image1.image = [UIImage imageNamed:@"flower1.tiff"];
    image1.animationImages = image1Arr;
    image1.animationDuration = 1;
    image1.animationRepeatCount = 0;
    [self.view addSubview:image1];
    [image1 release];
    [image1 startAnimating];

UIImageView *image2 = [[UIImageView alloc] initWithFrame:CGRectMake(image1.frame.origin.x, image1.frame.origin.y + image1.frame.size.height + 10, 100, 100)];
NSMutableArray *image2Arr = [NSMutableArray array];
for (NSInteger i = 0; i < 18; i++) {
    NSString *imageName = [NSString stringWithFormat:@"flower%ld.tiff", i + 1];
    UIImage *image = [UIImage imageNamed:imageName];
    [image2Arr addObject:image];
}
image2.image = [UIImage imageNamed:@"flower1.tiff"];
image2.animationImages = image2Arr;
image2.animationDuration  = 1;
image2.animationRepeatCount = 0;
[self.view addSubview:image2];
[image2 release];
[image2 startAnimating];
// 豌豆射手
UIImageView *image3 = [[UIImageView alloc] initWithFrame:CGRectMake(image2.frame.origin.x, image2.frame.origin.y + image2.frame.size.height + 10, 120, 120)];
image2.image = [UIImage imageNamed:@"plants1.tiff"];
NSMutableArray *image3Arr = [NSMutableArray array];
for (NSInteger i = 0; i < 9; i++) {
    NSString *imageName = [NSString stringWithFormat:@"plants%ld.tiff", i + 1];
    UIImage *image = [UIImage imageNamed:imageName];
    [image3Arr addObject:image];
}
image3.animationRepeatCount = 0;
image3.animationDuration = 1;
image3.animationImages = image3Arr;
[self.view addSubview:image3];
[image3 release];
[image3 startAnimating];
// 窝瓜
UIImageView *image4 = [[UIImageView alloc]initWithFrame:CGRectMake(image3.frame.origin.x + 60, image3.frame.origin.y + image3.frame.size.height - 20, 120, 120)];
image4.image = [UIImage imageNamed:@"gua1.tiff"];
NSMutableArray *image4Arr = [NSMutableArray array];
for (NSInteger i = 0; i < 9; i++) {
    NSString *imageName = [NSString stringWithFormat:@"gua%ld.tiff", i + 1];
    UIImage *image = [UIImage imageNamed:imageName];
    [image4Arr addObject:image];
}
image4.animationImages = image4Arr;
image4.animationRepeatCount = 0;
image4.animationDuration = 0.5;
[self.view addSubview:image4];
[image4 release];
[image4 startAnimating];
// 僵尸
UIImageView *imgZombie = [[UIImageView alloc] initWithFrame:CGRectMake(image1.frame.origin.x + 100, image1.frame.origin.y, 150, 150)];
imgZombie.image = [UIImage imageNamed:@"zombie1.tiff"];
NSMutableArray *imgZombieArr = [NSMutableArray array];
for (NSInteger i = 0; i < 20; i++) {
    NSString *imageName = [NSString stringWithFormat:@"zombie%ld.tiff", i + 1];
    UIImage *image = [UIImage imageNamed:imageName];
    [imgZombieArr addObject:image];
}
imgZombie.animationImages = imgZombieArr;
imgZombie.animationRepeatCount = 0;
imgZombie.animationDuration = 1;
[self.view addSubview:imgZombie];
[imgZombie release];
[imgZombie startAnimating];
// 僵尸2
UIImageView *imgBZombie = [[UIImageView alloc] initWithFrame:CGRectMake(image3.frame.origin.x + 100, image3.frame.origin.y, 150, 150)];
imgZombie.image = [UIImage imageNamed:@"BZombie1.tiff"];
NSMutableArray *imgBZombieArr = [NSMutableArray array];
for (NSInteger i = 0; i < 20; i++) {
    NSString *imageName = [NSString stringWithFormat:@"BZombie%ld.tiff", i + 1];
    UIImage *image = [UIImage imageNamed:imageName];
    [imgBZombieArr addObject:image];
}
imgBZombie.animationImages = imgBZombieArr;
imgBZombie.animationRepeatCount = 0;
imgBZombie.animationDuration = 1;
[self.view addSubview:imgBZombie];
[imgBZombie release];
[imgBZombie startAnimating];

// YIem的博客

}

屏幕快照 2016-01-14 上午8.52.32.png
屏幕快照 2016-01-14 上午8.52.46.png
屏幕快照 2016-01-14 上午8.52.54.png
屏幕快照 2016-01-14 上午8.53.01.png
屏幕快照 2016-01-14 上午8.53.10.png
屏幕快照 2016-01-14 上午8.53.18.png

// Created by YIem on 16/1/13.
// Copyright © 2016年 www.yiem.net YIem博客. All rights reserved.
//

标签: none

添加新评论

Title - Artist
0:00