Inheritance: java.lang.Object
            public void onSensorChanged(SensorEvent e)
            {
                //[javac]
                //           Compiling 610 source files to W:\bin\classes
                //   [javac] W:\src\AndroidAccelerometerActivity\Activities\AndroidAccelerometerActivity_MySensorEventListener.java:43: error: bad operand types for binary operator '>'
                //[javac]             if (((this.onaccelerometer > null)))


                // check sensor type
                if (e.sensor.getType() == Sensor.TYPE_ACCELEROMETER)
                {

                    // assign directions
                    float x = e.values[0];
                    float y = e.values[1];
                    float z = e.values[2];

                    if (onaccelerometer != null)
                        onaccelerometer(x, y, z);
                }
            }
            public void onSensorChanged(SensorEvent e)
            {

                // check sensor type
                //if (e.sensor.getType() == Sensor.TYPE_ACCELEROMETER)
                if (e.sensor.getType() == Sensor.TYPE_ORIENTATION)
                {
                    //                values[0]: Azimuth - (the compass bearing east of magnetic north)
                    //values[1]: Pitch, rotation around x-axis (is the phone leaning forward or back)
                    //values[2]: Roll, rotation around y-axis (is the phone leaning over on its left or right side)

                    // this is different than the browser device orientation.
                    float x = e.values[0];
                    float y = e.values[1];
                    float z = e.values[2];

                    if (onaccelerometer != null)
                        onaccelerometer(x, y, z);
                }
            }
Esempio n. 3
0
 public void onSensorChanged(SensorEvent arg0)
 {
     myShipVelocity.X = -arg0.values[0];
     myShipVelocity.Y = -arg0.values[1];
     myShipVelocity.Z = 0;
     myShipVelocity = myShipVelocity.Normalize().Scale(200f);
 }