Files
esengine/source/src/Physics/Shapes/Shape.ts
2020-07-27 16:10:36 +08:00

28 lines
1.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
module es {
export abstract class Shape {
/**
* 有一个单独的位置字段可以让我们改变形状的位置来进行碰撞检查而不是改变entity.position。
* 触发碰撞器/边界/散列更新的位置。
* 内部字段
*/
public position: Vector2;
/**
* 这不是中心。这个值不一定是物体的中心。对撞机更准确。
* 应用任何转换旋转的localOffset
* 内部字段
*/
public center: Vector2;
/** 缓存的形状边界 内部字段 */
public bounds: Rectangle;
public abstract recalculateBounds(collider: Collider);
public abstract overlaps(other: Shape): boolean;
public abstract collidesWithShape(other: Shape, collisionResult: CollisionResult): boolean;
public abstract pointCollidesWithShape(point: Vector2, result: CollisionResult): boolean;
public clone(): Shape{
return ObjectUtils.clone<Shape>(this);
}
}
}