fix cocos-creator/fireball/issues/5484

This commit is contained in:
knoxHuang
2017-04-18 09:18:03 +08:00
parent 2d69c0ca59
commit 004abc3b66
2 changed files with 7 additions and 9 deletions
+1 -9
View File
@@ -118,16 +118,8 @@ var SystemEvent = cc.Class({
if (!accelerationListener) {
accelerationListener = cc.EventListener.create({
event: cc.EventListener.ACCELERATION,
callback: function (accelEvent, event) {
callback: function (acc, event) {
event.type = EventType.DEVICEMOTION;
// fix android acc values are opposite
if (!CC_JSB && cc.sys.os === cc.sys.OS_ANDROID &&
cc.sys.browserType !== cc.sys.BROWSER_TYPE_MOBILE_QQ) {
event.acc = cc.p(-accelEvent.x, -accelEvent.y);
}
else {
event.acc = cc.p(accelEvent.x, accelEvent.y);
}
cc.systemEvent.dispatchEvent(event);
}
});
@@ -125,4 +125,10 @@ inputManager.didAccelerate = function (eventData) {
mAcceleration.x = -mAcceleration.x;
mAcceleration.y = -mAcceleration.y;
}
// fix android acc values are opposite
if (!CC_JSB && cc.sys.os === cc.sys.OS_ANDROID &&
cc.sys.browserType !== cc.sys.BROWSER_TYPE_MOBILE_QQ) {
mAcceleration.x = -mAcceleration.x;
mAcceleration.y = -mAcceleration.y;
}
};