box 重载 collidesWith

This commit is contained in:
yhh
2020-07-07 12:18:51 +08:00
parent 8be65fa685
commit ace8fb685d
12 changed files with 204 additions and 6 deletions

View File

@@ -21,6 +21,20 @@ class Box extends Polygon {
return verts;
}
/**
*
* @param other
*/
public collidesWithShape(other: Shape){
if (this.isUnrotated && other instanceof Box && other.isUnrotated){
return ShapeCollisions.boxToBox(this, other);
}
// TODO: 让 minkowski 运行于 cricleToBox
return super.collidesWithShape(other);
}
public updateBox(width: number, height: number){
this.width = width;
this.height = height;