nape-js API
    Preparing search index...

    Class InteractionListener

    Listener for interaction events between two interactors.

    Fires when two objects matching options1 and options2 start, continue, or stop interacting with each other according to interactionType.

    Valid events: CbEvent.BEGIN, CbEvent.ONGOING, CbEvent.END.

    • BEGIN fires once when the interaction starts.
    • ONGOING fires every simulation step while the interaction persists.
    • END fires once when the interaction ends.
    const listener = new InteractionListener(
    CbEvent.BEGIN,
    InteractionType.COLLISION,
    playerType,
    groundType,
    (cb) => { console.log('player landed'); },
    );
    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