nape-js API
    Preparing search index...

    Class CbType

    Callback type tag — used to label bodies, shapes, and constraints so that listeners can selectively respond to interactions involving specific objects.

    Objects can carry multiple CbTypes (via their cbTypes list). Listeners match against those types using OptionType include/exclude filters, or using the built-in singletons (ANY_BODY, ANY_SHAPE, etc.).

    const playerType = new CbType();
    body.cbTypes.add(playerType);

    const listener = new InteractionListener(
    CbEvent.BEGIN,
    InteractionType.COLLISION,
    playerType,
    null,
    (cb) => { console.log('player hit something'); },
    );
    space.listeners.add(listener);

    Converted from nape-compiled.js lines 689–770.

    Index

    Constructors

    Accessors

    • get userData(): Record<string, unknown>

      Arbitrary user data attached to this CbType.

      Lazily initialized to {} on first access. Use to store application-level metadata associated with the type.

      Returns Record<string, unknown>

    Methods