标签:
//实现边框左右的排布
for (int j=0; j<<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8">700; j=j+367) {
for (int i=0; i<<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8">500; i++) {
UILabel*biankuang2=[[UILabel alloc]initWithFrame:CGRectMake(j, i*10, 8, 8)];
if (i%3==0) {
biankuang2 .backgroundColor=[UIColor redColor];
}else if (i%3==1){
biankuang2 .backgroundColor=[UIColor blueColor];
}else{
biankuang2 .backgroundColor=[UIColor blackColor];
}
[self.view addSubview:biankuang2];
}
}
////////////////////////////////////////////////////////////////////////
// 下面的_time1是控制三个障碍图片运动
_time1=[NSTimer scheduledTimerWithTimeInterval:.1 target:self selector:@selector(move1) userInfo:nilrepeats:YES];
// 下面的_time2时控制雷区出现地雷
_time2=[NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(diLei)userInfo:nil repeats:YES];
//判断是否相撞
_time3=[NSTimer scheduledTimerWithTimeInterval:.02 target:self selector:@selector(crash)userInfo:nil repeats:YES];
}
///////////////////////////////////////跳出页面程序
// 碰撞检测
-(void)fly{
_snowFlake.center=CGPointMake(_snowFlake.center.x-_qq, _snowFlake.center.y+_qq);
if (_snowFlake.center.x<<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8">5) {
_snowFlake.center=CGPointMake(388, _snowFlake.center.y);
}else if (_snowFlake.center.y>666){
_snowFlake.center=CGPointMake(_snowFlake.center.x, 66);
}
}
-(void)crash{
if (CGRectIntersectsRect(_iv4.frame, _iv3.frame)||CGRectIntersectsRect(_iv4.frame,_iv2.frame)||CGRectIntersectsRect(_iv4.frame, _iv.frame)||CGRectIntersectsRect(_iv4.frame, _iv5.frame)) {
_iv4.center=CGPointMake(120, 650);
//实现了发生碰撞一次剩余血量就减一
_blood--;
//这里的text一定要放在这里写。显示剩余剩余血量。
_lb1.text=@(_blood).stringValue;
if (_blood<<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8">1) {
UILabel*over=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 400, 666 )];
over.text=@"大菜逼,重来吧!";
over.font=[UIFont systemFontOfSize:50 weight:33];
over.textColor=[UIColor redColor];
over.backgroundColor=[UIColor blueColor]
;
[self.view addSubview:over];
}
_level++;
_lb2.text=@(_level).stringValue;
// ********每个_kk的值在控制图片运动的时候有负值,所以在这里加上
// if判断是否为正数,如果是正数就加,负的就减
if (_kk>0) {
_kk+=10;
}else{
_kk+=-10;
}
if (_kk2>0) {
_kk2+=10;
}else{
_kk2+=-10;
}
if (_kk3>0) {
_kk3+=10;
}else{
_kk3+=-10;
}
////////
if (_level>=2) {
UIImageView*good=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 380, 666)];
good.image=[UIImage imageNamed:@"08.jpg"];
[self.view addSubview:good];
}
标签:
原文地址:http://www.cnblogs.com/lanyisanqqi/p/5067864.html