飞机游戏+跟踪导弹源码
点击次数:36 次 发布日期:2008-11-21 23:33:48 作者:源代码网
点击浏览该文件
有1000多行代码,所以以前有过的很多东西我就不发了。
源代码网供稿.// 发射火箭 开始 rocketshoot = function (rocketname, sx, sy, RocketSpeed, TargetMc, DefaultArg) { // rocketname导弹名字,sx,sy初始位置,rocketspeed 速度,目标MC,默认角度 var newRocket = _root.attachMovie(rocketname, "rocket"+rdepth, rdepth++);//rdepth 为导弹深度 newRocket._x = sx; newRocket._y = sy; if (rdepth>4300) { rdepth = 4001; } //控制导弹数量在一定范围内 var oldarg = DefaultArg/180*Math.PI; //创建一个默认角度 newRocket.onEnterFrame = function() { var argnow = getangle(newRocket, TargetMc)/180*Math.PI; // getangle通过得到一个原MC和一个目标MC得到2者间的角度 if (!isNaN(argnow)) { //如果得到的角度为正常 oldarg = argnow; // 将得到的角度保存 } else { argnow = oldarg; //如果为非法,将上次保存的值取出 } var rot = argnow*180/Math.PI+90; newRocket._rotation = rot;//导弹自转 this._x += Math.cos(argnow)*RocketSpeed; this._y += Math.sin(argnow)*RocketSpeed; mcht(this, 10); // mc的hittest函数,专为计算已方发射的武器的一些判断 if (this._x<100 || this._y<0 || this._x>540 || this._y>480) { removeMovieClip(this); //出界删除 } }; }; // 发射火箭 结束 |

点击浏览该文件