mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 16:12:40 +08:00
fix cocos-creator/fireball/issues/5484
This commit is contained in:
@@ -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;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user