[]Native IOS下获取陀螺仪数据为0

通过Gyroscope获取陀螺仪相关信息返回的RotationInfo,在Native IOS平台下获得的值为:
alpha = 90,而beta和gamma始终为0. 左右和上下翻转手机都没有变化。
同样的接口,在Native Android平台和web (IOS 和Android都行)平台上都是OK的。
 
NativePlayer SDK使用的是最新的0.9.10。
 
可能是Native IOS没有支持好?看文档IOS平台会无法获得绝对访问数据,但应该能获得设备决定的任意坐标系。

//设置陀螺仪的处理
Laya.Gyroscope.instance.on(Laya.Event.CHANGE, this, this.onOrientationChange);
 

private onOrientationChange(absolute:Boolean, info: Laya.RotationInfo):void
        {
            if (info.alpha === null)
            {
                     console.log("当前设备不支持陀螺仪。");
                     //去掉陀螺仪的移动
                     Laya.Gyroscope.instance.off(Laya.Event.CHANGE, this, this.onOrientationChange);
                     return;
            }
            console.log(`alpha = ${info.alpha} beta = ${info.beta} gamma = ${info.gamma} and x = ${this.imgBg.centerX} y = ${this.imgBg.centerY}`);
         }
 
已邀请:

Laya_XS

赞同来自:

加速器里本身是不支持陀螺仪使用的,后面版本可能会支持!

要回复问题请先

商务合作
商务合作