Restrict the input from the gyro to the same range as desktop version.

Also ensures that starting position when using gyro is "in the middle", and not the position corresponding to the top left corner when using mouse.
This commit is contained in:
Patrik Thunström 2013-04-26 21:36:11 +02:00
Родитель 98acc32964
Коммит 253f033680
1 изменённых файлов: 7 добавлений и 0 удалений

Просмотреть файл

@ -31,6 +31,7 @@
layers = [],
plaxActivityTarget = $(window),
motionMax = 1,
motionMin = -1,
motionStartX = null,
motionStartY = null,
ignoreMoveable = false
@ -168,6 +169,12 @@
// Admittedly fuzzy measurements
x = values.x / 30
y = values.y / 30
// Ensure not outside of expected range, -1 to 1
x = x < motionMin ? motionMin : (x > motionMax ? motionMax : x)
y = y < motionMin ? motionMin : (y > motionMax ? motionMax : y)
// Normalize from -1 to 1 => 0 to 1
x = (x + 1) / 2
y = (y + 1) / 2
}
var hRatio = x/((moveable() == true) ? motionMax : plaxActivityTarget.width()),