diff --git a/cocos2dx/platform/android/nativeactivity.cpp b/cocos2dx/platform/android/nativeactivity.cpp index 63846f0ac3..473cf445e3 100644 --- a/cocos2dx/platform/android/nativeactivity.cpp +++ b/cocos2dx/platform/android/nativeactivity.cpp @@ -598,7 +598,7 @@ void android_main(struct android_app* state) { // ACONFIGURATION_ORIENTATION_PORT // ACONFIGURATION_ORIENTATION_SQUARE cocos2d::Acceleration acc; - acc.x = event.acceleration.x/10; + acc.x = -event.acceleration.x/10; acc.y = -event.acceleration.y/10; acc.z = event.acceleration.z/10; acc.timestamp = 0; @@ -609,7 +609,7 @@ void android_main(struct android_app* state) { // ACONFIGURATION_ORIENTATION_LAND // swap x and y parameters cocos2d::Acceleration acc; - acc.x = -event.acceleration.y/10; + acc.x = event.acceleration.y/10; acc.y = -event.acceleration.x/10; acc.z = event.acceleration.z/10; acc.timestamp = 0; diff --git a/samples/Cpp/TestCpp/Classes/AccelerometerTest/AccelerometerTest.cpp b/samples/Cpp/TestCpp/Classes/AccelerometerTest/AccelerometerTest.cpp index 7fa2e58162..4f06570737 100644 --- a/samples/Cpp/TestCpp/Classes/AccelerometerTest/AccelerometerTest.cpp +++ b/samples/Cpp/TestCpp/Classes/AccelerometerTest/AccelerometerTest.cpp @@ -69,7 +69,7 @@ void AccelerometerTest::onAcceleration(Acceleration* acc, Event* event) auto ptNow = _ball->getPosition(); auto ptTemp = pDir->convertToUI(ptNow); - ptTemp.x -= acc->x * 9.81f; + ptTemp.x += acc->x * 9.81f; ptTemp.y -= acc->y * 9.81f; auto ptNext = pDir->convertToGL(ptTemp);