加速度计检测左右运动
有人可以给我一个例子来说明如何检测 iPhone 是否向左移动或向右移动。就像摇晃的长版本一样,我希望我的应用程序能够知道用户的手臂是向右还是向左。想象一下你的手像雨刷器一样,末端有手机,
有什么想法吗?
谢谢,山姆:P
can someone please give me an example of how you detect if the iphone is moving left or moving right. like a long version of a shake i want my app to be able to know if the users arm is going right or left. imagine your hand like a window wiper with the phone at the end
any ideas?
Thanks, Sam :P
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这就是 Acceleration.x 值。想象一下 3 条线穿过你的 iPhone:
1) 一条垂直于 iPhone 屏幕并穿过它的线,即 Z。
2)一条与屏幕平行的水平线,即X(您正在寻找的)。
3) 一条与屏幕垂直且平行的线,即 Y。
因此,向左或向右移动 iPhone 将会在 X 图中产生变化。向上或向下移动 iPhone 将会在 Y 图中产生变化。向前或向后移动 iPhone 将会在 Z 图中产生变化。
希望这可以帮助您掌握加速度计的概念,
〜纳塔纳夫拉。
That would be the acceleration.x value. Imagine 3 lines going through your iPhone:
1) a line perpendicular to your iPhone screen and going through it, that would be Z.
2) a horizontal and parallel line to your screen, that would be X (what you're looking for).
3) a vertical and parallel line to your screen, that would be Y.
So, moving the iPhone left or right will generate changes in the X graph. Moving the iPhone up or down will generate changes in the Y graph. Moving your iPhone forward or backward will generate changes in the Z graph.
Hope this helps you grasp the accelerometer's concept,
~ Natanavra.