新增collidesWithAny方法

This commit is contained in:
yhh
2021-04-14 10:44:33 +08:00
parent e1365ed343
commit 5e15543bab
4 changed files with 97 additions and 46 deletions

View File

@@ -212,5 +212,24 @@ module es {
return false;
}
/**
* 检查此碰撞器是否与场景中的其他碰撞器碰撞。它相交的第一个碰撞器将在碰撞结果中返回碰撞数据。
* @param result
*/
public collidesWithAny(result: CollisionResult = new CollisionResult()) {
// 在我们的新位置上获取我们可能会碰到的任何东西
let neighbors = Physics.boxcastBroadphaseExcludingSelfNonRect(this, this.collidesWithLayers.value);
for (let neighbor of neighbors) {
if (neighbor.isTrigger)
continue;
if (this.collidesWithNonMotion(neighbor, result))
return true;
}
return false;
}
}
}