mirror of https://github.com/axmolengine/axmol.git
fixed #643, swap accelerometer input x/y according to the orientation (on ios devices)
This commit is contained in:
parent
a8835649fe
commit
4244fdb62b
|
@ -84,6 +84,29 @@ static AccelerometerDispatcher* s_pAccelerometerDispatcher;
|
|||
accelerationCpp.z = acceleration.z;
|
||||
accelerationCpp.timestamp = acceleration.timestamp;
|
||||
|
||||
double tmp = accelerationCpp.x;
|
||||
|
||||
switch ([[UIApplication sharedApplication] statusBarOrientation])
|
||||
{
|
||||
case UIInterfaceOrientationLandscapeRight:
|
||||
accelerationCpp.x = -acceleration.y;
|
||||
accelerationCpp.y = tmp;
|
||||
break;
|
||||
|
||||
case UIInterfaceOrientationLandscapeLeft:
|
||||
accelerationCpp.x = acceleration.y;
|
||||
accelerationCpp.y = -tmp;
|
||||
break;
|
||||
|
||||
case UIInterfaceOrientationPortraitUpsideDown:
|
||||
accelerationCpp.x = -accelerationCpp.y;
|
||||
accelerationCpp.y = -tmp;
|
||||
break;
|
||||
|
||||
case UIInterfaceOrientationPortrait:
|
||||
break;
|
||||
}
|
||||
|
||||
for (AccelerometerDelegateWrapper *wrapper in delegateWrappers) {
|
||||
[wrapper didAccelerate: &accelerationCpp];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue