欢迎光临
我们一直在努力

打飞机

建站超值云服务器,限时71元/月

打飞机

项目介绍:

之前看到过几次,感觉这小游戏很不错,今天写出来给大家分享一下。游戏很简单,初学者也能学会的。

#import "ViewController.h"
#define kWindowWidth                        [[UIScreen mainScreen] bounds].size.width
#define kWindowHeight                       [[UIScreen mainScreen] bounds].size.height
@interface ViewController ()
{
    NSInteger floatWeight;
    NSTimer *timer;
    NSInteger fen;
}
@property (nonatomic ,strong) UIImageView *bgImg1;
@property (nonatomic ,strong) UIImageView *bgImg2;
@property (nonatomic ,strong) UIImageView *myPlane;
@property (nonatomic ,strong) NSMutableArray *diJiArray;
@property (nonatomic ,strong) NSMutableArray *ziDanArray;
@property (nonatomic ,strong) UIImageView *baozha;
@property (nonatomic ,strong) NSMutableArray *baozhaArray;
@property (nonatomic ,strong) UILabel *fenLab;

@end

内容主要围绕几个定时器来搞得。

    fen = 0;
    [self.view addSubview:self.bgImg1];
    [self.view addSubview:self.bgImg2];
    [self.view addSubview:self.myPlane];
    [self.view addSubview:self.baozha];
    [self.view addSubview:self.fenLab];
    //创建控制地图移动的定时器
    [NSTimer scheduledTimerWithTimeInterval:.05 target:self selector:@selector(mapMove) userInfo:nil repeats:YES];
    //创建找敌机的定时器
    [NSTimer scheduledTimerWithTimeInterval:.2 target:self selector:@selector(findDiJi) userInfo:nil repeats:YES];
    //创建控制敌机下落的定时器
    [NSTimer scheduledTimerWithTimeInterval:.05 target:self selector:@selector(downDiJi) userInfo:nil repeats:YES];
    //创建找子弹的定时器
    [NSTimer scheduledTimerWithTimeInterval:.1 target:self selector:@selector(findZiDan) userInfo:nil repeats:YES];
    //发射子弹
    [NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(fireZiDan) userInfo:nil repeats:YES];
    //创建爆炸的定时器
    timer =   [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(baoZha) userInfo:nil repeats:YES];

code4app

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 打飞机
分享到: 更多 (0)