简体   繁体   English

播放时发生声音加速

[英]While playing sound acceleration occurs

I am developing one game where I want to move UIImageView based on accelerometer. 我正在开发一款想要基于加速度计移动UIImageView的游戏。 When I rotate iphone device left to right or right to left the UIImageView have to rotate in particular angle. 当我左右左右旋转iphone设备时,UIImageView必须旋转特定角度。 It's moving also but the problem occurs when I play background sound because of that sound, it sends some acceleration point even if my iphone is idle. 它也在移动,但是当我播放背景音时会出现问题,因为它发出声音,即使我的iphone处于空闲状态,它也会发送一些加速点。 So my UIImageView is also moving. 所以我的UIImageView也正在移动。 It should not happen. 它不应该发生。 When I decrease the iphone sound volume it works very well. 当我降低iPhone的音量时,效果很好。 What I have to do for that. 我必须为此做些什么。

And also if anyone knows how to get acceleration point only when iphone is moving from left to right or right to left. 而且,如果有人知道如何仅在iPhone从左向右或从右向左移动时获得加速点。 It should not detect when iphone is xz or yz plane. 它不应检测iphone是xz还是yz平面。

If anybody knows the solution please reply. 如果有人知道解决方案,请回复。

Have you got any filtering on the input from the accelertometer? 您是否对加速度计的输入进行了滤波? I would expect the noise from the speaker the accelerometer is picking up is vastly different in amplitude and frequency than the game control. 我希望加速度计接收到的扬声器发出的噪声在幅度和频率上与游戏控件大不相同。

There is a simple low pass filter in the Apple accelerometer graph sample code. Apple加速度计图形示例代码中有一个简单的低通滤波器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM