[碰撞实现\数学实现非mc检测]
作者 佚名技术
来源 服务器技术
浏览
发布时间 2012-07-13
entListener(event:String, handler):Void{} // //broadcaster for test collision/refresh. private static var __testCollisionBroadcaster:xp.gameLib.reflect.ReflectorBroadcaster=undefined ; // // //event list: private var __f_hit:Function; private var __f_collide:Function; private var __f_passed:Function; // var onHit:Function; var onCollide:Function; var onPassed:Function; // //list of mc which will be test private var testList:Array; // // // //component parameters for config this plane,& also could be set in runtime. // // //visual effect clip’s linkage id. [Inspectable(defaultValue="",type="String")] var clipName:String = "ef"; // var clipIns:MovieClip; // //if it is a double side plane. [Inspectable(defaultValue=false,type="Boolean")] var doubleSide:Boolean = false; // // //friction: // //f>0; //0:+oo friction //1:no friction; [Inspectable(defaultValue=0,type="Number")] var f:Number = 0; // // //elasticity: // //0:no elasticity,object will be sticked after collision. //>0:reflect after collision; //>1:speed up & reflect. //<0:get through,but slow down. //<-1:get through,and speed up. [Inspectable(defaultValue=0,type="Number")] var e:Number = 0; // //u could add a force to a mc while it touch it. [Inspectable(defaultValue=0,type="Number")] var xForce = 0; // [Inspectable(defaultValue=0,type="Number")] var yForce = 0; // // // var _enabled:Boolean = true; // function set enabled (e:Boolean) { _enabled = e; // //update old position record: if (e) { for (var i = 0; i < testList.length; i++) { var o = testList[i]; //remove dead links. if (o.ins == undefined) { testList.splice (i, 1); i--; continue; } //new position o.v1.x = o.ins._x; o.v1.y = o.ins._y; // o.ins._parent.localToGlobal (o.v1); this.globalToLocal (o.v1); } } } function get enabled(){ return _enabled; } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function Reflector () { super (); // testList = new Array (); // //create visual effect clip if (clipName==undefined || clipName=="") clipName="ef"; clipIns= this.attachMovie (clipName, "1", 1); // if (!__testCollisionBroadcaster) { __testCollisionBroadcaster = new xp.gameLib.reflect.ReflectorBroadcaster() } __testCollisionBroadcaster.addChildListener (this); // this.addEventListener ("onHit", this); this.addEventListener ("onCollide", this); this.addEventListener ("onPassed", this); // update (); } // function addTarget (o:MovieClip) { testList.push ({ins:o, v1:{x:0, y:0}, v2:{x:0, y:0}}); this.addEventListener ("onHit", o); this.addEventListener ("onCollide", o); this.addEventListener ("onPassed", o); } // function removeTarget (o:MovieClip) { for (var i = 0; i < testList.length; i++) { if (testList[i].ins == o) { testList.splice (i, 1); } } } // function resetPosition(p:MovieClip) { for (var i = 0; i < testList.length; i++) { if (tes |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |
你可能对下面的文章感兴趣
上一篇: 浅谈飞机游戏碰撞检测代码的处理方式下一篇: 镜头推拉的效果
关于[碰撞实现\数学实现非mc检测]的所有评论