我如何将 iPhone 运动检测用于类似摇蛋的应用程序?
我希望构建一个类似于那些摇蛋应用程序的应用程序,以更好地理解如何在 iPhone 上检测运动。我一直在研究加速度计方法以及运动和运动方法,但似乎无法完成我想做的事情。
我的具体需求如下:我希望能够在用户将手机摇开时播放一种声音,并在用户向他们摇动手机时播放另一种声音。用户的动作与摇蛋器非常相似,根据他们是否将设备移向或远离胸部,可以播放两种不同的声音。测量它们离开或靠近的强度也是很好的。
有什么想法吗?
我在苹果的示例代码中搜索了类似的应用程序,但似乎没有。
I am hoping to build an application similar to those egg shaking applications, to better understand how to detect motion on the iphone. I've been looking at accelerometer methods and motion and motion methods, but can't seem to get working what I want to do.
The specifics of my need are as follows: I want to be able to play one sound when user shakes the phone away from them, and play another sound when they shake back towards them. The motion from the user would be very similar to an egg shaker, with two different sounds able to be played depending on whether they moved the device towards or away from their chest. It would also be good to measure the intensity with which they moved away or towards.
Any ideas?
I've searched apple's sample code for a similar application, but there doesnt seem to be one.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看看这个开源游戏,它充分利用了加速度计。能够知道自己要去哪个方向是一件好事,但我并没有在强度上搞砸太多。我相信一旦你了解了细节就很容易了。
http://github.com/haqu/tweejump
Look at this game which is open source and makes great use of the accelerometer. It's a good one to be able to tell which direction you are going, but I haven't messed around much with intensity. I'm sure it's easy enough once you get into the details.
http://github.com/haqu/tweejump