nape-js API
    Preparing search index...

    Class ConstraintListener

    Listener for constraint lifecycle events.

    Fires when a constraint matching the options filter wakes, sleeps, or breaks.

    Valid events: CbEvent.WAKE, CbEvent.SLEEP, CbEvent.BREAK.

    A BREAK event fires when the constraint exceeds its maxForce or maxError limit. If removeOnBreak is true on the constraint it is also removed from the space.

    const listener = new ConstraintListener(
    CbEvent.BREAK,
    myConstraintType,
    (cb) => { console.log(cb.constraint, 'broke!'); },
    );
    space.listeners.add(listener);

    Hierarchy (View Summary)

    Index
    • get precedence(): number

      Execution priority of this listener relative to other listeners for the same event and objects. The direction depends on the listener type (inherited from Haxe nape):

      • BodyListener / ConstraintListener: higher values run first; on a tie the listener added last runs first.
      • InteractionListener / PreListener: lower values run first; on a tie the listener added first runs first. When several PreListeners return a flag for the same pair the last one called wins — so the highest precedence has the final say.

      Returns number

      0

    • set precedence(precedence: number): void

      Parameters

      • precedence: number

      Returns void