Merge pull request #10442 from Dhilan007/v3-accelerometer-fix

Fixed Accelerometer has lagged on iOS
This commit is contained in:
minggo 2015-02-12 17:20:07 +08:00
commit 3a4e9ced46
1 changed files with 3 additions and 0 deletions

View File

@ -38,6 +38,8 @@
#import<CoreMotion/CoreMotion.h> #import<CoreMotion/CoreMotion.h>
#import<CoreFoundation/CoreFoundation.h> #import<CoreFoundation/CoreFoundation.h>
#define SENSOR_DELAY_GAME 0.02
@interface CCAccelerometerDispatcher : NSObject<UIAccelerometerDelegate> @interface CCAccelerometerDispatcher : NSObject<UIAccelerometerDelegate>
{ {
cocos2d::Acceleration *_acceleration; cocos2d::Acceleration *_acceleration;
@ -69,6 +71,7 @@ static CCAccelerometerDispatcher* s_pAccelerometerDispatcher;
if( (self = [super init]) ) { if( (self = [super init]) ) {
_acceleration = new cocos2d::Acceleration(); _acceleration = new cocos2d::Acceleration();
_motionManager = [[CMMotionManager alloc] init]; _motionManager = [[CMMotionManager alloc] init];
_motionManager.accelerometerUpdateInterval = SENSOR_DELAY_GAME;
} }
return self; return self;
} }