GestureInfo
The gesture info is carried by gesture event, record the info of one gesture.
| Type | Name | Interface Description |
|---|---|---|
| Variables | duration: number | • Function: The duration of long-tap gesture. Only valid for LongTap gesture. The value is in milliseconds. |
| Variables | endPoint: Vector2f | • Function: The gesture end position of this gesture. Valid for all gesture types. The value is 0 - 1. 0 is the top-left corner of the screen. 1 is the bottom-right corner of the screen. |
| Variables | firstTrigger: boolean | • Function: Start dragging. When a drag-and-drop action occurs, a series of Drag events will be received. This flag can be used to obtain the event that triggered the drag-and-drop action. Only valid when gesture type is Drag. |
| Variables | startPoint: Vector2f | • Function: The gesture start position of this gesture. Only valid when gesture type is Drag or Drop. The value is 0 - 1. 0 is the top-left corner of the screen. 1 is the bottom-right corner of the screen. |
| Variables | type: GestureType | • Function: The gesture type of this gesture. |
| Functions | constructor() |
Examples
firstTrigger: boolean
Control the position of an object by drag gesture.
const gestureEmitter = APJS.EventManager.getGestureEmitter();
const dragCallback = (event:APJS.IEvent) => {
const gestureInfo = event.args[0] as APJS.GestureInfo;
if (gestureInfo.firstTrigger) {
this.currentDragStartPoint = gestureInfo.startPoint;
this.startAnchoredPosition = this.imageTransform.anchoredPosition;
}
const offset = gestureInfo.endPoint.clone().subtract(this.currentDragStartPoint);
this.imageTransform.anchoredPosition = offset.multiply(new APJS.Vector2f(screenResolution.x, -screenResolution.y)).add(this.startAnchoredPosition);
}
gestureEmitter.on(APJS.GestureType.Drag, dragCallback);
constructor()
let obj = new APJS.GestureInfo();
Use Case
@component()
export class NewBehaviourScript extends APJS.BasicScriptComponent {
onStart() {
// TODO: instantiate / use GestureInfo here
}
onUpdate(deltaTime: number) {
}
}