0
在我的應用程序中,當我存檔(產品 - >存檔)的份額獲得.api然後去itunes並安裝在我的iPhone我有設備控制檯中注意accelX總是等於零爲什麼?爲什麼accelX總是等於零?
注意,如果我在Xcode點擊播放一切工作正常
這是我的代碼:
- (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;
}
但是沒有理由有'(滾動X *(1.0 - kFilteringFactor));'因爲它總是計算爲0 .. – Carter
@Carter:只是第一次,它會給零零滾動X不同於零 –