加速计(加速度传感器)
检测设备是否支持加速计
const isSupport = await ymx.isSupportAccelerometer();alert(isSupport ? '支持' : '不支持'); 复制
const isSupport = await ymx.isSupportAccelerometer();alert(isSupport ? '支持' : '不支持');
移除加速计数据事件的监听函数,不传 listener 则移除所有监听函数
可选
//移除全部加速计监听器await ymx.offAccelerometerChange(); 复制
//移除全部加速计监听器await ymx.offAccelerometerChange();
监听加速计数据事件
await ymx.onAccelerometerChange((res) => { console.log(`Accelerometer x:${res.x}, y:${res.y}, z:${res.z}`);}); 复制
await ymx.onAccelerometerChange((res) => { console.log(`Accelerometer x:${res.x}, y:${res.y}, z:${res.z}`);});
开始监听加速计数据
await ymx.startAccelerometer({ interval: 200}); 复制
await ymx.startAccelerometer({ interval: 200});
停止监听加速计数据
await ymx.stopAccelerometer(); 复制
await ymx.stopAccelerometer();
加速计(加速度传感器)