Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PhysicsContact

PhysicsContact will be generated during begin and end collision as a parameter of the collision callback. Note that contacts will be reused for speed up cpu time, so do not cache anything in the contact.

Hierarchy

  • PhysicsContact

Index

Properties

Private _b2contact

_b2contact: b2ContactExtends | null = null

Private _impulse

_impulse: b2.ContactImpulse | null = null

Private _inverted

_inverted: boolean = false

colliderA

colliderA: Collider2D | null = null

colliderB

colliderB: Collider2D | null = null

disabled

disabled: boolean = false

disabledOnce

disabledOnce: boolean = false

Methods

setImpulse

  • setImpulse(impulse: b2.ContactImpulse | null): void

emit

  • emit(contactType: any): void

getFriction

  • getFriction(): number

getImpulse

  • getImpulse(): null | { normalImpulses: number[]; tangentImpulses: number[] }
  • Get the impulses. Note: PhysicsImpulse can only used in onPostSolve callback.

    method

    getImpulse

    Returns null | { normalImpulses: number[]; tangentImpulses: number[] }

getManifold

  • Get the manifold.

    method

    getManifold

    Returns { localNormal: Vec2; localPoint: Vec2; points: ManifoldPoint[]; type: number }

    • localNormal: Vec2
      en

      -e_circles: not used -e_faceA: the normal on polygonA -e_faceB: the normal on polygonB

      zh

      -e_circles: 没被使用到 -e_faceA: polygonA 的法向量 -e_faceB: polygonB 的法向量

      property

      {Vec2} localNormal

    • localPoint: Vec2
      en

      The local point usage depends on the manifold type: -e_circles: the local center of circleA -e_faceA: the center of faceA -e_faceB: the center of faceB

      zh

      用途取决于 manifold 类型 -e_circles: circleA 的本地中心点 -e_faceA: faceA 的本地中心点 -e_faceB: faceB 的本地中心点

      property

      {Vec2} localPoint

    • points: ManifoldPoint[]
      en

      the points of contact.

      zh

      接触点信息。

      property

      {[ManifoldPoint]} points

    • type: number
      en

      Manifold type : 0: e_circles, 1: e_faceA, 2: e_faceB

      zh

      Manifold 类型 : 0: e_circles, 1: e_faceA, 2: e_faceB

      property

      {Number} type

getRestitution

  • getRestitution(): number

getTangentSpeed

  • getTangentSpeed(): number

getWorldManifold

  • getWorldManifold(): { normal: Vec2; points: Vec2[]; separations: number[] }
  • Get the world manifold.

    method

    getWorldManifold

    Returns { normal: Vec2; points: Vec2[]; separations: number[] }

    • normal: Vec2
      en

      world vector pointing from A to B

      zh

      世界坐标系下由 A 指向 B 的向量

      property

      {Vec2} normal

    • points: Vec2[]
      en

      world contact point (point of intersection)

      zh

      碰撞点集合

      property

      {[Vec2]} points

    • separations: number[]
      en

      a negative value indicates overlap

      zh

      一个负数,用于指明重叠的部分

init

isTouching

  • isTouching(): boolean

reset

  • reset(): void

resetFriction

  • resetFriction(): void

resetRestitution

  • resetRestitution(): void

setEnabled

  • setEnabled(value: any): void

setFriction

  • setFriction(value: any): void

setRestitution

  • setRestitution(value: any): void

setTangentSpeed

  • setTangentSpeed(value: any): void

Static get

Static put

Generated using TypeDoc