nape-js API
    Preparing search index...

    Class Shape

    Base class for physics shapes (Circle, Polygon). Never instantiated directly — use new Circle(...) or Polygon.box(...) etc.

    Hierarchy (View Summary)

    Index
    • get sensorEnabled(): boolean

      If true, this shape acts as a sensor (no physical response, only callbacks).

      Cannot be changed during space.step(), which includes PreListener handlers (they run mid-step). Record the desired state in the handler and apply it after step() returns. Body / interaction / constraint listener callbacks are delivered after the step and may change it directly.

      Returns boolean

    • set sensorEnabled(value: boolean): void

      Parameters

      • value: boolean

      Returns void

    • Return true if the given world-space point lies inside this shape. Requires the shape to be attached to a Body.

      Parameters

      • point: Vec2

        The world-space point to test.

      Returns boolean

      True if the point is inside this shape.

    • Scale the shape's local geometry. Circles require uniform scaling.

      Parameters

      • scaleX: number

        Horizontal scale factor (must be non-zero).

      • scaleY: number

        Vertical scale factor (must be non-zero).

      Returns Shape

      this for chaining.