GestureEvent
更新时间:2021-06-17
此类封装GestureEvent相关数据与操作,包含手势事件的基本数据。
Public methods | |
---|---|
GestureEvent | type 获取gesture的类型属性 |
GestureEvent | time 获取gesture的当前时间属性 |
GestureEvent | pos 获取gesture的中心位置属性 |
GestureEvent | swipe_direction 获取gesture的当前轻扫方向属性 |
GestureEvent | delta_angle 获取双指旋转手势相对上一帧手势转动的弧度数值 |
GestureEvent Demo
GestureEvent GestureEventDemo ()
demo示例
sample:
function on_gesture_update(gesture)
local type = gesture.type
end
type
API起始版本:190
string type
获取gesture的类型属性
"gesture_click"-单指点击
"gesture_double_click"-单指双击
"gesture_long_press"-单指长按
"gesture_swipe"-轻扫
"gesture_scroll"-单指滑动
"gesture_two_fingle_scroll"-双指滑动
"gesture_two_finger_pinch"-双指靠近
"gesture_two_finger_unpinch"-双指远离
"gesture_two_finger_rotate"-双指旋转
"gesture_clear"-手势结束
sample:
function on_gesture_update(gesture)
local type = gesture.type
end
time
API起始版本:190
long time
获取gesture的当前时间属性,单位:ms
sample:
function on_gesture_update(gesture)
local time = gesture.time
end
pos
API起始版本:190
ARVec2 pos
获取gesture的中心位置属性
sample:
function on_gesture_update(gesture)
local pos = gesture.pos
local x = pos.x
local y = pos.y
end
swipe_direction
API起始版本:190
string swipe_direction
获取gesture的当前轻扫方向属性,仅在手势类型(type)为轻扫("gesture_swipe")时有效,即非"swipe_none"方向
"swipe_none"-未知轻扫方向
"swipe-right"-向右轻扫
"swipe-left"-向左轻扫
"swipe_up"-向上轻扫
"swipe_down"-向下轻扫
sample:
function on_gesture_update(gesture)
if (gesture.type == "gesture_swipe") then
local swipe_direction = gesture.swipe_direction
end
end
delta_angle
API起始版本:190
float delta_angle
获取双指旋转手势相对上一帧手势转动的弧度数值,仅在手势类型(type)为双指旋转("gesture_two_finger_rotate")时有效,即为非0数值
sample:
function on_gesture_update(gesture)
if (gesture.type == "gesture_two_finger_rotate") then
local delta_angle = gesture.delta_angle
end
end