InteractionListener

Listenernape.callbacks.InteractionListener (final class)

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.

_Space
/      \
Cmp1        Cmp3
/    \         |
Body1  Cmp2     Body3
|      |        |
Shp1   Body2    Shp3
|
Shp2

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:

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.

Instance Members

@private


nape
options1: OptionType

The OptionType used to match against Interactors for the first object.


nape
options2: OptionType

The OptionType used to match against Interactors for the second object.


nape
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.


nape
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.


nape
handler(): Void

The callback handler for this listener.


nape
new(event: CbEvent, interactionType: InteractionType, options1: Null<Dynamic>, options2: Null<Dynamic>, handler: Function, ?precedence: Int = 0): Void

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.

Name Type Default Description
event CbEvent The event type to listen for.
interactionType InteractionType The interaction type to listen for.
options1 Null<Dynamic> The OptionType to match first Interactor against, passing null will equate to an empty OptionType.
options2 Null<Dynamic> The OptionType to match second Interactor against, passing null will equate to an empty OptionType.
handler Function The callback handler for this listener.
precedence Int 0 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)

Private Members

Metadata

Name Parameters
:final -