-
Creator 版本:3.8
-
目标平台:微信小游戏
-
重现方式:
-
手机型号:HUAWEI P40
-
手机浏览器: 微信扫码
代码如下:
start() {
// 监听摇晃
input.setAccelerometerEnabled(true); // 打开加速度计
input.on(Input.EventType.DEVICEMOTION, this.onDeviceMotionEvent, this);
}
onDeviceMotionEvent (event: EventAcceleration) {
console.log(“触发摇晃事件”);
console.log(event.acc.x + " " + event.acc.y);
}