@@ -35,15 +35,31 @@ Handle the <accelerationChanged> message if you want to perform an
3535action when the acceleration along any axis changes
3636
3737The <accelerationChanged> message is sent to the current card of the
38- defaultStack at the interval specified by the mobileEnableAccelerometer
39- command.
38+ defaultStack at the interval specified by the
39+ <mobileEnableAccelerometer> command.
4040
4141You can use the difference between the time values in two
4242<accelerationChanged> events to give an indication of how much time
4343passed between the samples.
4444
45+ >*Note:* On Android, the change in acceleration output is in meters
46+ > per second squared whereas on iOS, it is in G-forces. In order to
47+ > normalize these changes in acceleration, you must detect the
48+ > <platform> and convert appropriately. For example:
49+
50+ on accelerationChanged pXAccel, pYAccel, pZAccel
51+ if the platform is "iphone" then
52+ -- Convert from g-forces to m/s^2
53+ multiply pXAccel by 9.81
54+ multiply pYAccel by 9.81
55+ multiply pZAccel by 9.81
56+ end if
57+ -- the rest of your code
58+ end accelerationChanged
59+
4560References: mobileStopTrackingSensor (command),
46- mobileStartTrackingSensor (command)
61+ mobileStartTrackingSensor (command),
62+ mobileEnableAccelerometer (command), platform (function)
4763
4864Tags: ui
4965
0 commit comments