使用 Corona SDK 不需要事件监听器来使用加速度计。

我想要在我的游戏中编写一个方法,它在特定时间点只使用“加速计重力”,因此我不希望有事件侦听器不断调用使用加速度计作为事件的方法。

我想要做的是这样的:

local function exampleFunction()
    if accelerometer.xGravity > exampleValue then
        print("success")
    end
end

但不幸的是,您不能像变量一样调用加速度计。

我应该怎么做?

谢谢

点赞
用户825481
用户825481

在 Corona 示例代码中有一个具有加速度计事件的示例。它会在运行时监听器中打印出 x、y、z 坐标。请查看该示例,但要注意,Corona 中加速度计的 API 取决于设备。一些 Android 设备的响应速度不如其他设备。

2014-03-17 19:52:10