2020-06-12 08:47:13 +08:00
|
|
|
///<reference path="./Shape.ts" />
|
|
|
|
|
class Circle extends Shape {
|
|
|
|
|
public radius: number;
|
|
|
|
|
private _originalRadius: number;
|
|
|
|
|
|
|
|
|
|
constructor(radius: number){
|
|
|
|
|
super();
|
|
|
|
|
this.radius = radius;
|
|
|
|
|
this._originalRadius = radius;
|
|
|
|
|
}
|
2020-06-12 20:24:51 +08:00
|
|
|
|
|
|
|
|
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`);
|
|
|
|
|
}
|
2020-06-12 08:47:13 +08:00
|
|
|
}
|