1 | ;
|
2 |
|
3 | /**
|
4 | * Holds the current orientation of the device if the device has an accelerometer. An instance of Accelerometer is available as {@link Splat.Game#accelerometer}.
|
5 | * @constructor
|
6 | */
|
7 | function Accelerometer() {
|
8 | /**
|
9 | * The angle of the device rotated around the z-axis. The z-axis is the axis coming out of the device screen. alpha represents how much the devies is spun around the center of the screen.
|
10 | * @member {number}
|
11 | */
|
12 | this.alpha = 0;
|
13 | /**
|
14 | * The angle of the device rotated around the x-axis. The x-axis is horizontal across the device screen. beta represents how much the device is tilted forward or backward.
|
15 | * @member {number}
|
16 | */
|
17 | this.beta = 0;
|
18 | /**
|
19 | * The angle of the device rotated around the y-axis. The y-axis is vertical across the device screen. gamma represents how much the device is turned left or right.
|
20 | * @member {number}
|
21 | */
|
22 | this.gamma = 0;
|
23 |
|
24 | var self = this;
|
25 | window.addEventListener("deviceorientation", function(event) {
|
26 | self.alpha = event.alpha;
|
27 | self.beta = event.beta;
|
28 | self.gamma = event.gamma;
|
29 | }, false);
|
30 | }
|
31 |
|
32 | module.exports = Accelerometer;
|