Options
All
  • Public
  • Public/Protected
  • All
Menu

多边形的特殊情况。在进行SAT碰撞检查时,我们只需要检查2个轴而不是8个轴

Hierarchy

Index

Constructors

constructor

  • new Box(width: number, height: number): Box

Properties

_areEdgeNormalsDirty

_areEdgeNormalsDirty: boolean = true

_edgeNormals

_edgeNormals: Vector2[]

_originalPoints

_originalPoints: Vector2[]

多边形的原始数据

_polygonCenter

_polygonCenter: Vector2

bounds

bounds: Rectangle

缓存的形状边界 内部字段

center

center: Vector2

这不是中心。这个值不一定是物体的中心。对撞机更准确。 应用任何转换旋转的localOffset 内部字段

height

height: number

isBox

isBox: boolean

用于优化未旋转box碰撞

isUnrotated

isUnrotated: boolean = true

points

points: Vector2[]

组成多边形的点 保持顺时针与凸边形

position

position: Vector2

有一个单独的位置字段可以让我们改变形状的位置来进行碰撞检查,而不是改变entity.position。 触发碰撞器/边界/散列更新的位置。 内部字段

width

width: number

Accessors

edgeNormals

Methods

buildEdgeNormals

  • buildEdgeNormals(): void

collidesWithLine

collidesWithShape

containsPoint

  • containsPoint(point: Vector2): boolean

overlaps

  • overlaps(other: Shape): any

pointCollidesWithShape

recalculateBounds

  • recalculateBounds(collider: Collider): void

recalculateCenterAndEdgeNormals

  • recalculateCenterAndEdgeNormals(): void

setPoints

  • setPoints(points: Vector2[]): void

updateBox

  • updateBox(width: number, height: number): void
  • 更新框点,重新计算中心,设置宽度/高度

    Parameters

    • width: number
    • height: number

    Returns void

Static Private buildBox

  • buildBox(width: number, height: number): Vector2[]

Static buildSymmetricalPolygon

  • buildSymmetricalPolygon(vertCount: number, radius: number): any[]

Static findPolygonCenter

Static getClosestPointOnPolygonToPoint

Static getFarthestPointInDirection

Static recenterPolygonVerts

  • recenterPolygonVerts(points: Vector2[]): void

Static rotatePolygonVerts

  • rotatePolygonVerts(radians: number, originalPoints: Vector2[], rotatedPoints: Vector2[]): void

Generated using TypeDoc