快速业务通道

飞机躲避小游戏-是男人就撑100秒的制作

作者 佚名技术 来源 服务器技术 浏览 发布时间 2012-07-08
icfunctioninitPos(targetPlane:CSPhyMc):Void
{
varrandNum:Number=random(100);
//setinitpositoin:down,left,up,right
if(randNum<25)
{
this._x=random(Stage.width);
trace("Width"+Stage.width+"Height"+Stage.height);

this._y=Stage.height;
}
elseif(randNum<50)
{
thisP._x=_root.gStageLeft;
this._y=random(Stage.height);
}
elseif(randNum<75)
{
this._x=random(Stage.width);
thisP._y=_root.gStageTop;
}
else
{
this._x=Stage.width;
this._y=random(Stage.height);
}

this.CalVx_Vy(this,targetPlane);
}

privatefunctionGetDis(mc1:CSPhyMc,mc2:CSPhyMc):Number
{
returnMath.sqrt((mc1._x-mc2._x)*(mc1._x-mc2._x)+(mc1._y-mc2._y)*(mc1._y-mc2._y));
}

privatefunctionCalVx_Vy(mcChase:CSPhyMc,mcAim:CSPhyMc):Void
{
varlen:Number=GetDis(mcChase,mcAim);
mcChase.vx=(mcAim._x-mcChase._x)/len*mcChase.v;
mcChase.vy=(mcAim._y-mcChase._y)/len*mcChase.v;
}

publicfunctioninitCom():Void
{
mMotionCom=newRCSMove();
mColDetCom=newRCSColDet();
}

publicfunctionoutDetect():Boolean
{
varoffset:Number=25;
returnmColDetCom.particleOutDet(this,0-offset,0-offset,Stage.width+2*offset,Stage.height+2*offset);
}

publicfunctionmove_show():Void
{
mMotionCom.Move2D(this,this.vx,this.vy);
}

publicfunctioncollideDect(targetPlane:CSPhyMc):Boolean
{
if(_root.mcLibPlaneName=="ball")
returnmColDetCom.TwoBall(targetPlane,this);
//returnthis.hitTest(targetPlane.getBounds(_root).xMin,targetPlane.getBounds(_root).yMax,false);
}
}4.2游戏主调度类
classChaseAim
{
staticprivatevarthisP:Object;
privatevarstaturs:Number;//gaming1,failure0
privatevarspeed:Number;
privatevarbulletNum:Number=20;
privatevarstart:Number=0;
privatevarend:Number=0;
publicfunctioninit():Void
{thisP=this;
staturs=1;
speed=3;
bulletNum=20;
for(vari=0;i<11;i++)
{
_root.createTextField("txt"+i,i,0,(i-1)*25,500,25);
}

_root.attachMovie("ball","ball1",11);
_root.ball1._x=250;
_root.ball1._y=200;
_root.ball1.r=20;

for(vari=0;i<bulletNum;i++)
{
_root.attachMovie("bullet","bullet"+i,20+i);
_root["bullet"+i].vx=0;
_root["bullet"+i].vy=0;
_root["bullet"+i].v=3+random(3);
_root["bullet"+i].r=5;
_root["bullet"+i]._width=10;
_root["bullet"+i]._height=10;

GenBullet(_root["bullet"+i]);
}
start=getTimer();

setInterval(EffectF,100);
}

privatefunctionEffectF():Void
{
if(thisP.staturs!=0)
{
for(vari=0;i<thisP.bulletNum;i++)
{
if(thisP.CheckOutBounds(_root["bullet"+i]))thisP.GenBullet(_root["bullet"+i]);
if(thisP.TwoBallCol(_root.ball1,_root["bullet"+i]))thisP.staturs=0;
thisP.Move2D(_root["bullet"+i]);
//_root.txt3.text=_root["bullet"+i].vx;
//_root.txt4.text=_root["bullet"+i].vy;

}


if(Key.isDown(Key.LEFT))_root.ball1._x-=thisP.speed;
if(Key.isDown(Key.RIGHT))_root.ball1._x+=thisP.speed;
if(Key.isDown(Key.UP))_root.ball1._y-=thisP.speed;
if(Key.isDown(Key.DOWN))_root.ball1._y+=thisP.speed;
if(thisP.staturs==0)
{
_root.txt0.text="youfailure";
thisP.end=getTimer();
vartmp:Number=thisP.end-thisP.start;
_root.txt1.text="你共坚持了"+tmp/1000+"秒";
//deletethis.onEnterFrame;
}
}
}

privatefunctionGenBullet(tmpMc:CSPhyMc):Void
{varleft:Number;

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号