Game Development Reference
In-Depth Information
The directions of the arrows in the previous diagram show the directions in which
acceleration will yield a positive value. This means that if you hold the device level
with the display upwards in front of you, tipping it to the right will yield a positive
value on the x axis accelerometer, tipping it away from you will generate positive
y axis values and moving the device vertically upwards will generate a positive
z axis value.
The Marmalade SDK provides us with access to the accelerometers of a device
using the s3eAccelerometer API, which we can use in our code by including the
s3eAccelerometer.h ile.
Starting and stopping accelerometer input
Before attempting to use the accelerometer in our program, we must first check to
see if accelerometer input is available on our device. If support is available, then
we can start receiving accelerometer input. We do this with the following check:
if (s3eAccelerometerGetInt(S3E_ACCELEROMETER_AVAILABLE) != 0)
{
// Accelerometer is available! Start receiving input.
s3eAccelerometerStart();
}
When we have finished using the accelerometers, we just make a call to
s3eAccelerometerStop and we will receive no further inputs.
 
Search WWH ::




Custom Search