Event listener for Interaction type events.
Interaction type events can occur between any two Interactors (whether they
be Shapes, Bodys, Compounds or a mix thereof).
The events that can be caught are BEGIN, ONGOING, and END type events.
Theses listeners will operate between pairs of Interactors.
The possible interactor pairs for callbacks are formed by finding the most recent common ancestor in the world for the given pair of shapes and taking all possible pairings. In the above situation we have:_Space / \ Cmp1 Cmp3
/ \ | Body1 Cmp2 Body3 | | | Shp1 Body2 Shp3
| Shp2
MRCA(Shp1, Shp2) = Cmp1 --> Possible pairings = [Shp1, Body1] x [Shp2, Body2, Cmp2] MRCA(Shp1, Shp3) = Space --> Possible pairings = [Shp1, Body1, Cmp1] x [Shp3, Body3, Cmp3] MRCA(Shp2, Shp3) = Space --> Possible pairings = [Shp2, Body2, Cmp2, Cmp1] x [Shp3, Body3, Cmp3]Of course, not all of these pairings will generate callbacks, only those for which a valid listener exists for the event type, and for the cbtypes of each interactor.
Furthermore, the listener specifies an interaction type which works even in mixed cases where many types of interaction between two objects is happening at once.
Constructor
new(event:CbEvent, interactionType:InteractionType, options1:Null<Dynamic>, options2:Null<Dynamic>, handler:InteractionCallback ‑> Void, precedence:Int = 0)
Construct a new InteractionListener.
The possible event types are BEGIN, ONGOING and END.
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.
Parameters:
event | The event type to listen for. |
---|---|
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) |
Returns:
The newly constructed InteractionListener
Throws:
# | If handler is null. |
---|---|
# | If the event type is not permitted for this listener. |
# | If either option is not of the expected Type. |
Variables
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.
allowSleepingCallbacks:Bool
For ONGOING listeners only, permit ONGOING callbacks whilst sleeping.
This property determines whether we will still receive
ONGOING callbacks between two sleeping Interactors. The default action is to
inhibit callbacks between sleeping objects for performance. Setting this field to true
will permit Nape to always generate callbacks.