collider更改

This commit is contained in:
yhh
2020-07-20 16:38:49 +08:00
parent 2a38858838
commit 6b8569b0b5
13 changed files with 110 additions and 196 deletions

View File

@@ -1,7 +1,17 @@
class RectangleExt {
/**
* 计算两个矩形的并集。结果将是一个包含其他两个的矩形。
* @param first
* @param point
*/
public static union(first: Rectangle, point: Vector2){
let rect = new Rectangle(point.x, point.y, 0, 0);
let rectResult = first.union(rect);
return new Rectangle(rectResult.x, rectResult.y, rectResult.width, rectResult.height);
// let rectResult = first.union(rect);
let result = new Rectangle();
result.x = Math.min(first.x, rect.x);
result.y = Math.min(first.y, rect.y);
result.width = Math.max(first.right, rect.right) - result.x;
result.height = Math.max(first.bottom, result.bottom) - result.y;
return result;
}
}