[碰撞实现\数学实现非mc检测]
作者 佚名技术
来源 服务器技术
浏览
发布时间 2012-07-13
tList[i].ins == p) { var o=testList[i]; //new position o.v2.x = o.ins._x; o.v2.y = o.ins._y; // o.ins._parent.localToGlobal (o.v2); this.globalToLocal (o.v2); return; } } } // function testCollision () { if (!_enabled) { return; } // 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; } var re:Object; //new position o.v2.x = o.ins._x; o.v2.y = o.ins._y; // o.ins._parent.localToGlobal (o.v2); this.globalToLocal (o.v2); // re=new Object(); var flag:Boolean=collisionCalculate (o.v1, o.v2,o.ins,re); // this.localToGlobal (o.v2); o.ins._parent.globalToLocal (o.v2); if (flag) { //calculate result position, in MC’s own coordinates var rp={x:re.x0+re.vvx,y:re.y0+re.vvy}; this.localToGlobal(rp); o.ins._parent.globalToLocal(rp); //calculate collision position,in MC’s own coordinates. var rp0={x:re.x0,y:re.y0}; this.localToGlobal(rp0); o.ins._parent.globalToLocal(rp0); //get velocity. rp.x-=rp0.x; rp.y-=rp0.y; //event dispatching: //clip event & onXXX event. // this.__f_hit (); this.dispatchEvent ({type:"onHit", position:{x:o.v2.x,y:o.v2.y},hitPosition:{x:re.x0,y:re.y0},velocity:{x:re.vvx,y:re.vvy},rv:{x:rp.x,y:rp.y}}); // if (e >= 0) { this.__f_collide (); this.dispatchEvent ({type:"onCollide", position:{x:o.v2.x,y:o.v2.y},hitPosition:{x:re.x0,y:re.y0},velocity:{x:re.vvx,y:re.vvy},rv:{x:rp.x,y:rp.y}}); } else { this.__f_passed (); this.dispatchEvent ({type:"onPassed", position:{x:o.v2.x,y:o.v2.y},hitPosition:{x:re.x0,y:re.y0},velocity:{x:re.vvx,y:re.vvy},rv:{x:rp.x,y:rp.y}}); } } //record old position for next test. o.v1.x = o.ins._x; o.v1.y = o.ins._y; o.ins._parent.localToGlobal (o.v1); this.globalToLocal (o.v1); } // updateAfterEvent(); } // // //v1 / v2 are objects with properties ’x’ & ’y’,in this coordinates function collisionCalculate (v1, v2,ins,result):Boolean { //Vx result.vvx=0; //Vy result.vvy=0; //X result.x0=0; //Y result.y0=0; return false; } //re-calculate reflector data. function update() {} } 关键词:数学 |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |
你可能对下面的文章感兴趣
上一篇: 浅谈飞机游戏碰撞检测代码的处理方式下一篇: 镜头推拉的效果
关于[碰撞实现\数学实现非mc检测]的所有评论