Matt McCarthy edited Our Prototype1.tex  about 10 years ago

Commit id: 4737f9bfe8d2c8538345eed2455edee9c14b2fba

deletions | additions      

       

\subsection{Sensors}  The sensors are retrieved from the system sensor manager service, as the default accelerometer and rotation vector sensors for the device. Listeners are then registered to the sensors through the sensor manager. The main java file implements SensorChangeListener, and so changes to the values of registered sensors trigger the onSensorChanged method.  Two boolean values are initialized to false within the application, used to determine whether values for the sensors have been initialised. On a sensor event, these values are set to true according to the sensor type.  Within the onSensorChanged method, if the event sensor is of type accelerometer, the variable for player speed is set relative to the value of the accelerometer z axis. If the event sensor type is rotation vector, the values are stored in the variable 'rotationValues'. Within the rotation vector sensor event, if both sensors have provided initial values, the method changeMapDirection is called.  Changes in the registered sensors' values trigger the onSensorChanged method. If the event sensor is of type accelerometer, the variable for player speed is set relative to the value of the accelerometer z axis. If the event sensor type is rotation vector, the values are stored in the variable 'rotationValues'.