This section describes how to use the mobile device accelerometer to test for a shake event. Perhaps you want to allow the user to clear the data on the screen just by shaking the device.
PhoneGap and the Profound UI Mobile Client provide the following API to monitor the accelerometer:
watchId = accelerometer.watchAcceleration( accelerometerSuccess, accelerometerErr, accelerometerOptions )
The accelerometer is a motion sensor that detects the change (delta) in movement relative to the current position of the device. The accelerometer can detect 3D movement along the x, y, and z axis. The accelerometer.watchAcceleration API gets the current acceleration of the device at regular intervals. Each time the acceleration is retrieved, the accelerometerSuccess callback function is executed. You can specify the interval in milliseconds via the frequency parameter in the acceleratorOptions object.
The returned watch ID references the accelerometer watch process. The watch ID can be used with accelerometer.clearWatch to stop watching the accelerometer.
A shake event can be caught by measuring quick changes in the accelerometer. The sample code below shows how to accomplish this. The code can be placed in the app.js file. It looks for an element with the id of "shake" on the Profound UI Rich Display File screen and uses it to trigger the Shake action.
To utilize the above in a Profound UI RPG application, simply place a hidden button on the screen. Assign the id of "shake" to the button and bind the response property to a named indicator called Shake. Then, in your RPG code, simply test for the Shake event as follows: