YIem`s Blog -心比天高命比纸薄-链接找不到的请在站内搜索内容!

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

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

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController


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的博客


}






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

当前页面是本站的「Google AMP」版。查看和发表评论请点击:完整版 »