Package tripleplay.anim
Class Flicker
java.lang.Object
react.Slot<Object>
playn.scene.Pointer.Listener
tripleplay.anim.Flicker
- All Implemented Interfaces:
react.Reactor.RListener
,react.SignalView.Listener<Object>
,react.ValueView.Listener<Object>
Implements click, and scroll/flick gestures for a single variable (y position by default). When
the pointer is pressed and dragged, the scroll position is updated to track the pointer. If the
last two pointer events describe a motion of sufficiently high velocity, the scroll position is
"flicked" and undergoes (friction decelerated) motion. If the pointer is pressed and released
without scrolling or flicking, the
clicked
signal is emitted.
To use: create a flicker, configure it as a pointer listener on a layer that represents your
touchable area, then use position
to position your flickable layer (or to offset
your hand-drawn flickable elements) on every frame tick. You must also connect onPaint
to a paint signal (to process changes due to acceleration and velocity).
Various flick parameters can be customized by overriding the appropriate method:
friction()
, maxFlickVel()
, etc.
-
Field Summary
Modifier and TypeFieldDescriptionreact.Signal<Flicker>
A signal emitted when this flicker's position has changed.react.Signal<Pointer.Interaction>
A signal that is emitted (with the pointer end event) on click.react.Value<Boolean>
Whether or not this flicker is enabled (responding to pointer events).float
This flicker's bounds.float
This flicker's bounds.react.Slot<Clock>
This must be connected to a paint signal.float
The current position value. -
Constructor Summary
ConstructorDescriptionFlicker
(float initial, float min, float max) Creates a flicker with the specified initial, minimum and maximum values. -
Method Summary
Modifier and TypeMethodDescriptionConnects this flicker to thepaint
signal.void
freeze()
Aborts any active movement of this flicker.void
onDrag
(Pointer.Interaction iact) void
onEnd
(Pointer.Interaction iact) void
onStart
(Pointer.Interaction iact) posValue()
Returns the position of this flicker as an animation value.void
stop()
Stops any active movement of this flicker.Methods inherited from class playn.scene.Pointer.Listener
onCancel, onEmit
Methods inherited from class react.Slot
andThen, compose, filtered, onChange
-
Field Details
-
min
public float minThis flicker's bounds. -
max
public float maxThis flicker's bounds. -
position
public float positionThe current position value. -
changed
A signal emitted when this flicker's position has changed. -
clicked
A signal that is emitted (with the pointer end event) on click. -
enabled
Whether or not this flicker is enabled (responding to pointer events). Disabling a flicker does not stop any existing physical behavior, it just prevents the user from introducing any further behavior by flicking or tapping.Note that if a pointer interaction has already started when the flicker is disabled, that interaction will be allowed to complete. Otherwise the flicker would be left in an unpredictable state.
-
onPaint
This must be connected to a paint signal.
-
-
Constructor Details
-
Flicker
public Flicker(float initial, float min, float max) Creates a flicker with the specified initial, minimum and maximum values.
-
-
Method Details
-
connect
Connects this flicker to thepaint
signal. -
posValue
Returns the position of this flicker as an animation value. -
stop
public void stop()Stops any active movement of this flicker. The position is immediately clamped back intomin/max
which may be jarring if the flicker was in the middle of a rebound and outside its bounds. -
freeze
public void freeze()Aborts any active movement of this flicker. Zeroes out velocity and resets state to stopped. This differs fromstop()
in that it does not clamp the flicker's position back intomin/max
, so it should only be used if you plan to subsequently manually adjust the position to reflect valid values. Otherwise you may freeze the flicker while it's in a rebound state and not inside its normal bounds. -
onStart
- Overrides:
onStart
in classPointer.Listener
-
onDrag
- Overrides:
onDrag
in classPointer.Listener
-
onEnd
- Overrides:
onEnd
in classPointer.Listener
-