[英]why accelX always equal to zero?
in my app when i make archive (Product -> Archive) the share to get the .api then go to itunes and install in my iPhone I have notice in the device console that accelX always equal to zero why ?? 在我的应用程序中,当我进行归档(产品->归档文件)以获取.api的共享,然后转到iTunes并在iPhone中安装时,我在设备控制台中注意到accelX始终等于零,为什么?
Note if i click play in the xcode all work properly 请注意,如果我单击“ Xcode”中的“播放”,则一切正常
this is my code : 这是我的代码:
- (void)accelerometer:(UIAccelerometer *)accelerometer
didAccelerate:(UIAcceleration *)acceleration {
CGSize winSize = [CCDirector sharedDirector].winSize;
static float accelX = 0;
#define kFilteringFactor 0.1
#define kRestAccelX 0.6
#define kShipMaxPointsPerSec (winSize.height*0.5)
#define kMaxDiffX 0.2
UIAccelerationValue rollingX;
rollingX = (acceleration.x * kFilteringFactor) +
(rollingX * (1.0 - kFilteringFactor));
accelX = acceleration.x - rollingX;
NSLog(@"accelX :%f",accelX);
float accelDiffX = kRestAccelX - ABS(accelX);
float accelFractionX = accelDiffX / kMaxDiffX;
float pointsPerSecX = kShipMaxPointsPerSec * accelFractionX;
_shipPointsPerSecY = pointsPerSecX;
}
the solution is to replace: 解决方案是更换:
UIAccelerationValue rollingX;
by 通过
UIAccelerationValue rollingX = 0;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.