[LayaNative2]Touch is not defined
public static MoNiTouch(x, y): void {
var node=Laya.Render.canvas;
console.error("模拟触摸点:" + x + "," + y);
const touch = new Touch({
identifier: Date.now(),
target: node, // 目标元素
clientX: x, // 触摸点的X坐标
clientY: y // 触摸点的Y坐标
});
// // 创建一个TouchEvent对象
const touchStartEvent = new TouchEvent('touchstart', {
bubbles: true,//冒泡
cancelable: true,//取消
// touches: [touch],
changedTouches: [touch]
});
const touchEndEvent = new TouchEvent('touchend', {
bubbles: true,//冒泡
cancelable: true,//取消
// touches: [touch]
changedTouches: [touch]
});
node.dispatchEvent(touchStartEvent);
Laya.timer.once(
0.1,
this,
() => {
node.dispatchEvent(touchEndEvent);
}
);
}
想写个功能模拟在某个位置按下,这个代码在网页端能用,但是构建app后,报Touch is not defined。请问有没有好的解决方法。
没有找到相关结果
已邀请:
要回复问题请先登录
1 个回复
lv
赞同来自: