// RayCast方法:
// world.RayCast(callback:Function,point1:b2Vec2,point2:b2Vec2);
// * callback 回调函数
// * point1 射线的起点
// * point2 射线的终点
// 回调函数:
// function(fixture:b2Fixture,point:b2Vec2,normal:b2Vec2,fraction:Number):Number
// * fixture 定制器
// * point 碰撞点
// * normal 碰撞到的面的法线
// * fraction 起点到终点的距离*fraction=起点到碰撞点的距离
// * return 0 立即停止,根据遍历的顺序只找到一个fixture或到终点就停止
// * fraction 查找最近, 找出离起点最近的fixture或到终点就停止
// * 1 查找所有,找出从起点到终点所有与射线接触的fixture
// break
var world=Laya.Physics.I.world
world.RayCast(function(fixture,point,normal,fraction){
console.log("fixture",fixture)
console.log("point",point)
console.log("normal",normal)
console.log("fraction",fraction)
},{
x:300,
y:100
},{
x:300,
y:1000
})
//每碰到一个物体就会触发一次回调函数,没碰到物体就不会触发
//在回调函数里加上renturn 0 ,可以中断检测,比如只想检测碰到的第一个物体时可以用
搜了点box2d的资料,自己折腾了一会儿,大致理解了