Skip to content

Instantly share code, notes, and snippets.

@idimiter
Last active September 6, 2015 08:52
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save idimiter/f3dd1a706940da32534f to your computer and use it in GitHub Desktop.
Save idimiter/f3dd1a706940da32534f to your computer and use it in GitHub Desktop.
--- CCDevice.mm (revision 6)
+++ CCDevice.mm (working copy)
@@ -102,11 +102,12 @@
- (void)accelerometer:(CMAccelerometerData *)accelerometerData
{
- _acceleration->x = accelerometerData.acceleration.x;
- _acceleration->y = accelerometerData.acceleration.y;
- _acceleration->z = accelerometerData.acceleration.z;
- _acceleration->timestamp = accelerometerData.timestamp;
-
+#warning Get current data as opposite to the one from the queue. Its an ugly hack and needs to be replaced!
+ _acceleration->x = _motionManager.accelerometerData.acceleration.x;
+ _acceleration->y = _motionManager.accelerometerData.acceleration.y;
+ _acceleration->z = _motionManager.accelerometerData.acceleration.z;
+ _acceleration->timestamp = _motionManager.accelerometerData.timestamp;
+
double tmp = _acceleration->x;
switch ([[UIApplication sharedApplication] statusBarOrientation])
@jimrange
Copy link

The laggy issue that this fixes has existed since cocos2d-x 3.0 and currently exists in 3.5.
I hope that this or an alternative fix makes it into 3.6, since the laggyness/slowness is so significant that it seems to build up and make the accelerometer take up to 10 seconds to respond on iOS after running for about 30 seconds.

Thanks for posting this fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment