class nape.callbacks.PreListener extends Listener
Available on all platforms
Event listener for Pre-Interaction type events.
*
* Pre-Interaction type events can occur between any two Interactors (whether they
* be Shapes, Bodys, Compounds or a mix thereof).
Instance Fields
var interactionType:InteractionType
The specific type of interaction that is to be listened for.
*
* If we specify that we only want to listen for a fluid type interaction, then
* this listener will operate so that any other interactions for the same pair
* of objects is ignored.
Mark this listener as having a pure callback handler.
*
* A pure callback handler is one which under no circumstances will change its behaviour.
* In such a (favourable) instance, marking the callback as pure will allow Nape to permit
* objects in interaction to go to sleep even if the handler returns an IGNOREONCE/ACCEPTONCE
* PreFlag.
*
* @default false
function new(interactionType:InteractionType, options1:Null<Dynamic>, options2:Null<Dynamic>, handler:PreCallback ->Null<PreFlag>, ?precedence:Int = 0, ?pure:Bool = false):Void
Construct a new PreListener.
*
* The options arguments are typed Dynamic, and are permitted to be either an
* OptionType
or one of:
* CbType, CbTypeList, Array<CbType>, flash.Vector<CbType>
* In which case the input CbType's will be used to construct an OptionType
* whose included types will be the set of CbTypes supplied.
*
*
interactionType | The interaction type to listen for. * |
options1 | The OptionType to match first Interactor against, passing null * will equate to an empty OptionType. * |
options2 | The OptionType to match second Interactor against, passing null * will equate to an empty OptionType. * |
handler | The callback handler for this listener. * |
precedence | The precedence of this listener used to sort * the order of callbacks in the case of more than * one suitable BodyListener existing for the same * event on the same Body. (default 0) * |
pure | If true, then the listener will be marked as having a pure handler. * (default false) * |
returns | The newly constructed InteractionListener * |
function handler(:PreCallback):Null<PreFlag>
Callback handler for this listener.
*
* This callback handler returns a possibly null PreFlag object.
*
* Passing null is equivalent to telling nape 'ignore me' so that whatever existing
* decision has been made regarding the interaction is not modified.
* Otherwise returning a non-null PreFlag will change the current decision about what
* to do with the interaction.
*
* Returning ACCEPT/IGNORE inform nape to take control over all subsequent interaction
* between the two objects until they seperate. Returning these will mean that the pre
* listener will not be invoked again until the objects seperate, and then begin to interact
* afresh.
*
* Returning #ONCE, the objects will only be effected for a single step, and the following
* step should they still be candidates for interaction, this handler will be invoked again.
*
* In the case of a #ONCE, PreFlag; Nape will 'not' permit the two objects to go to sleep
* as Nape cannot know if this callback handler will suddenly changes its mind.
*
* If this handler is a 'pure' function, then you may mark it as such and Nape will keep you
* to your word and permit the objects to sleep.