accelerometer-object.md
Developer

Clickteam

Status

Supported

Available for MMF2 Icon MMF2 Developer Icon CF 2.5 Free Icon CF 2.5 Icon CF 2.5 Developer Icon
Supported Runtimes iOS logo Andriud logo HTML5 logo XNA logo Windows Phone logo
License Free
Includes Examples No
Includes Help Yes

The Accelerometer object allows you to receive information from the accelerometers from your mobile device (Android, iPhone, iPad etc.). Please note that the accelerometer hardware drains the battery of the device, and it is a good practice to turn it on only when necessary. The accelerometers are turned on when an Accelerometer object is present in the frame, at the start of the frame. They are turned off when the frame ends.

When you run an application on the PC with the object, it will return values of zero.

Contents

Conditions

Device orientation changed

This condition is true when the orientation of the device has changed. If this is the case, you can get the new orientation by using the Get current orientation expression of the object.

Expressions

Device orientation

Orientation( "Accelerometer object" )

This expression returns the current orientation of the device. A new orientation can be detected by triggering the “Device orientation changed” condition.

It returns values from 0 to 6:

  • Unknown (should not happen unless you shake the device)
  • Portrait
  • Portrait upside down
  • Landscape left
  • Landscape right
  • Face up
  • Face down

Direct values

X Acceleration

XDirect( "Accelerometer object" )

Y Acceleration

YDirect( "Accelerometer object" )

Z Acceleration

ZDirect( "Accelerometer object" )

These expressions return the raw values from the accelerometer. The accelerometers are not precise devices, the value will fluctuate very much, even if you do not touch the device.

Gravity isolated values

X Acceleration

XGravity( "Accelerometer object" )

Y Acceleration

YGravity( "Accelerometer object" )

Z Acceleration

ZGravity( "Accelerometer object" )

These expressions return the values from the accelerometer taking away the gravity factor. The accelerometers are not precise devices, the value will fluctuate very much, even if you do not touch the device.

Instantaneous values

X Acceleration

XInstant( "Accelerometer object" )

Y Acceleration

YInstant( "Accelerometer object" )

Z Acceleration

ZInstant( "Accelerometer object" )

These expressions return the values from the accelerometer from the last evaluation. The accelerometers are not precise devices, the value will fluctuate very much, even if you do not touch the device.