The kind of interaction to intercept (COLLISION, SENSOR, FLUID, or ANY).
Filter for the first interactor, or null to match any.
Filter for the second interactor, or null to match any.
Called each step; return a PreFlag to control the interaction.
Execution order relative to other listeners (higher = first). Default 0.
Result depends only on the pair, so the bodies may sleep. Default false.
The handler called before each collision resolution step.
Return a PreFlag to accept/ignore the interaction, or null to accept.
The type of interaction this pre-listener intercepts (COLLISION, SENSOR, FLUID, or ANY).
Filter for the first interactor. Order does not matter.
Filter for the second interactor. Order does not matter.
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.When true, the engine caches the handler return value and does not
re-invoke the handler until the cached result is invalidated.
Only use pure mode when the handler always returns the same flag for a
given pair of interactors. Setting pure to false immediately invalidates
any cached result.
The type of this listener (BODY, CONSTRAINT, INTERACTION, or PRE).
Pre-interaction listener — called before collision resolution each step.
The handler receives a PreCallback and returns a PreFlag that determines whether and how the interaction should be processed:
PreFlag.ACCEPT— resolve the interaction normally (default).PreFlag.IGNORE— suppress the interaction permanently (until nextBEGIN).PreFlag.ACCEPT_ONCE— accept this step, then revert to default.PreFlag.IGNORE_ONCE— ignore this step only.Returning
nullis equivalent toACCEPT.The event is always CbEvent.PRE and cannot be changed.
Caching comes from the returned flag:
ACCEPT/IGNOREare remembered and the handler is not called again until the nextBEGIN; the_ONCEvariants re-run it every step.Pure mode:
pure = truepromises the handler's result depends only on the pair, so the bodies may fall asleep while it returns a_ONCEflag. A non-pure listener (the default) keeps both bodies awake so it keeps running. Only usepurewhen the handler will always return the same flag for a given pair.Example