Gesture support for LayaAir engine.
Import library.
onGestureEvent(sprite: Laya.Sprite, gesture: string, caller: any, listener: (p1?: any, p2?: any, p3?: any, p4?: any) => void)
, see support Gesture:
LayaGestureManager.getInstance().onGestureEvent(this.img, Gesture.DOWN, this, this.mouseDown);
// mouse down callback
private mouseDown(x: number, y: number): void{
// ...
}
offGestureEvent(sprite: Laya.Sprite, gesture: string)
:
LayaGestureManager.getInstance().offGestureEvent(this.img, Gesture.DOWN);
offAllGestureEvent(sprite: Laya.Sprite)
:
LayaGestureManager.getInstance().offAllGestureEvent(this.img);
The support gesture, located in co.lujun.laya.gesture
.
Gesture | value(string) | callback | description |
---|---|---|---|
LONG_CLICK | co.lujun.laya.gesture.Gesture.long_click | () => void |
mouse long click |
DRAG | co.lujun.laya.gesture.Gesture.drag | (mouseSpriteX: number, mouseSpriteY: number) => void |
mouse drag |
SCALE | co.lujun.laya.gesture.Gesture.scale | (scaleX: number, scaleY: number, rotation: number) => void |
touch and scale |
FLING | co.lujun.laya.gesture.Gesture.fling | (speedX: number, speedY: number, mouseDownPoint: Laya.Point, mouseUpPoint: Laya.Point) => void |
mouse fling |
DOWN | co.lujun.laya.gesture.Gesture.down | (x: number, y: number) => void |
mouse down |
Enjoy it😄!
- First release.
If you have any questions, contact me: lujun.byte#gmail.com.