Touch Develop retirement postponed until June 22, 2019. Sign-in and access to cloud assets to be removed on May 23, 2018.Learn More..


Most phones and tablets now have a sensor called the accelerometer. This sensor measures the force applied to the device at any point time and you can use that information to build all kinds of cool games. Can you name a game where you have to move the phone?
So since we live in a 3D world, the accelerometer is going to report the forces as a 3D *vector, which contains the forces for the x, y and z axis.
var a := senses → acceleration quick
The z axis is the easiest to understand: if your phone is resting screen up on a table, the z axis shoots down towards the ground. In that case, the force returned by the accelerometer will be...
  • a->x = 0, a->y = 0, and a->z = 1 or in short a = (0, 0, 1).
Why is the value of a->z equal to 1? Well, remember that gravity is a force that is always active on earth -- otherwise you would be floating across the room right now -- and the accelerometer returns values scaled such that 9.81m/s^2 is equal to 1.

what if I don't have an accelerometer?

When your device does not have or does not expose the accelerometer sensor, the runtime uses the following strategy:
  • if the inclinometer sensor is available then an acceleration force is inferred from the orientation of the device. Unfortunately, it is not possible to determine if the device is shaken from this data.
  • if a mouse is available, the x and y values are simulated from the position of the mouse
  • if none of the options above work, the acceleration is always (0, 0, 1).