PreListener

Listenernape.callbacks.PreListener (final class)

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 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
pure: Bool

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 IGNORE_ONCE/ACCEPT_ONCE PreFlag.

@default false


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
handler(): 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.

Returns
Null<PreFlag>

nape
new(interactionType: InteractionType, options1: Null<Dynamic>, options2: Null<Dynamic>, handler: Function, ?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.

Name Type Default Description
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)
pure Bool false If true, then the listener will be marked as having a pure handler. (default false)

Private Members

Metadata

Name Parameters
:final -