新增shapecollision 用于计算多边形碰撞

This commit is contained in:
yhh
2020-06-12 20:24:51 +08:00
parent da5a1a0c79
commit 246e9a9511
18 changed files with 714 additions and 22 deletions

View File

@@ -8,4 +8,16 @@ class Circle extends Shape {
this.radius = radius;
this._originalRadius = radius;
}
public pointCollidesWithShape(point: Vector2): CollisionResult {
return ShapeCollisions.pointToCicle(point, this);
}
public collidesWithShape(other: Shape): CollisionResult{
if (other instanceof Rect && (other as Rect).isUnrotated){
return ShapeCollisions.circleToRect(this, other as Rect);
}
throw new Error(`Collisions of Circle to ${other} are not supported`);
}
}