Options
All
  • Public
  • Public/Protected
  • All
Menu

A shape is used for collision detection. Shapes are created in b2Body. You can use shape for collision detection before they are attached to the world. Warning: you cannot reuse shapes.

Hierarchy

Index

Constructors

Properties

e_circleShape: number
e_edgeShape: number
e_hitCollide: number

Return value for TestSegment indicating a hit.

e_missCollide: number

Return value for TestSegment indicating a miss.

e_polygonShape: number
e_shapeTypeCount: number
e_unknownShape: number
startsInsideCollide: number

Return value for TestSegment indicating that the segment starting point, p1, is already inside the shape.

Methods

  • Given a transform, compute the associated axis aligned bounding box for this shape.

    Parameters

    • aabb: b2AABB

      Calculated AABB, this argument is out.

    • xf: b2Transform

      Transform to calculate the AABB.

    Returns void

  • ComputeMass(massData: b2MassData, density: number): void
  • Compute the mass properties of this shape using its dimensions and density. The inertia tensor is computed about the local origin, not the centroid.

    Parameters

    • massData: b2MassData

      Calculate the mass, this argument is out.

    • density: number

      Density.

    Returns void

  • Compute the volume and centroid of this shape intersected with a half plane

    Parameters

    • normal: b2Vec2

      The surface normal.

    • offset: number

      The surface offset along the normal.

    • xf: b2Transform

      The shape transform.

    • c: b2Vec2

      The centroid, this argument is out.

    Returns number

  • GetType(): number
  • Get the type of this shape. You can use this to down cast to the concrete shape.

    Returns number

  • Test a point for containment in this shape. This only works for convex shapes.

    Parameters

    • xf: b2Transform

      Shape world transform.

    • p: b2Vec2

      Point to test against, in world coordinates.

    Returns boolean

    True if the point is in this shape, otherwise false.

  • Test if two shapes overlap with the applied transforms.

    Parameters

    • shape1: b2Shape

      shape to test for overlap with shape2.

    • transform1: b2Transform

      shape1 transform to apply.

    • shape2: b2Shape

      shape to test for overlap with shape1.

    • transform2: b2Transform

      shape2 transform to apply.

    Returns boolean

    True if shape1 and shape2 overlap, otherwise false.

Generated using TypeDoc