Package com.simsilica.lemur.event
Class TouchAppState
java.lang.Object
com.jme3.app.state.BaseAppState
com.simsilica.lemur.event.BasePickState
com.simsilica.lemur.event.TouchAppState
Similar to MouseAppState, this state adapts touch and multitouch
events to mouse and cursor events. In the case of multitouch,
each separate touch ID gets its own PickEventSession. For more
details on how a PickEventSession is handled, see MouseAppState
or PickEventSession.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classStorage class for the session and last location of the touch events for a single pointer (finger for touch).protected classTouchObserver provides the touch event data (pointer, x, and y) to the Lemur pick session for processing. -
Field Summary
FieldsFields inherited from interface com.simsilica.lemur.event.PickState
PICK_LAYER_GUI, PICK_LAYER_SCENE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcleanup(Application app) Called after the app state is detached or during application shutdown if the state is still attached.protected booleandispatchButton(TouchAppState.PointerData pointerData, boolean pressed) Dispatches a button action to the appropriate PickEventSession for the touch pointer provided.protected voidDispatches the last touch locations to the active PickEventSessions.protected TouchAppState.PointerDatagetPointerData(int pointerId, int x, int y) Returns (or creates) the PointerData object with the appropriate PickEventSession and X/Y coordinates for the provided pointerId.Methods inherited from class com.simsilica.lemur.event.BasePickState
addCollisionRoot, addCollisionRoot, addCollisionRoot, addCollisionRoot, findViewPort, getIncludeDefaultCollisionRoots, getPickLayerOrder, getSession, hasRequestedEnabled, initialize, onDisable, onEnable, releaseEnabled, removeCollisionRoot, removeCollisionRoot, requestEnabled, resetEnabled, setIncludeDefaultCollisionRoots, setPickLayerOrder, updateMethods inherited from class com.jme3.app.state.BaseAppState
cleanup, getApplication, getId, getState, getState, getState, getState, getStateManager, initialize, isEnabled, isInitialized, postRender, render, setEnabled, setId, stateAttached, stateDetachedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.jme3.app.state.AppState
cleanup, getId, initialize, isEnabled, isInitialized, postRender, render, setEnabled, stateAttached, stateDetached
-
Field Details
-
pointerDataMap
-
-
Constructor Details
-
TouchAppState
-
-
Method Details
-
cleanup
Description copied from class:BaseAppStateCalled after the app state is detached or during application shutdown if the state is still attached. onDisable() is called before this cleanup() method if the state is enabled at the time of cleanup.- Overrides:
cleanupin classBasePickState- Parameters:
app- the application
-
dispatchMotion
protected void dispatchMotion()Dispatches the last touch locations to the active PickEventSessions.
When touch motion events occur, the touch location is stored and then dispatched at the frequency defined to avoid sending more motions than necessary. An early out is provided if no PickEventSessions are active (ie. no touch pointers are active).- Specified by:
dispatchMotionin classBasePickState
-
dispatchButton
Dispatches a button action to the appropriate PickEventSession for the touch pointer provided.- Parameters:
pointerData- PointerData object for the appropriate touch pointerpressed- True when pressed, False when released- Returns:
- True if the PickEventSession consumed the event, False otherwise.
-
getPointerData
Returns (or creates) the PointerData object with the appropriate PickEventSession and X/Y coordinates for the provided pointerId.
The provided X and Y locations are stored in the PointerData object for created PointerData objects and updated if the PointerData object already exists.- Parameters:
pointerId- Touch pointer idx- X component of the touch location in pixelsy- Y component of the touch location in pixels- Returns:
- Associated PointerData object which contains the appropriate PickEventSession and X/Y coordinates of the last touch event
-