private void SetupAccelerometerReading()
        {
            // Movement of Pacman
            _lastUpdateTime = DateTime.Now;
            _currentPoint   = new PointF(0, 144);
            _motionManager  = new CMMotionManager();
            _motionManager.AccelerometerUpdateInterval = UPDATE_INTERVAL;

            _motionManager.StartAccelerometerUpdates(NSOperationQueue.CurrentQueue, (data, error) => {
                _acceleration = data.Acceleration;
                InvokeOnMainThread(UpdatePacman);
            });
        }
Exemple #2
0
        public void AccelerometerDidChange(CMAcceleration acceleration)
        {
            float filteringFactor = 0.5f;

            accelerometer.X = (float)acceleration.X * filteringFactor + accelerometer.X * (1f - filteringFactor);
            accelerometer.Y = (float)acceleration.Y * filteringFactor + accelerometer.Y * (1f - filteringFactor);
            accelerometer.Z = (float)acceleration.Z * filteringFactor + accelerometer.Z * (1f - filteringFactor);

            if (accelerometer.X > 0)
            {
                orientation = (float)(accelerometer.Y * 1.3f);
            }
            else
            {
                orientation = (float)(-accelerometer.Y * 1.3f);
            }
        }
        void Update()
        {
            if (motionManager.DeviceMotionActive)
            {
                CMDeviceMotion deviceMotion = motionManager.DeviceMotion;
                if (deviceMotion != null)
                {
                    CMAcceleration acceleration = deviceMotion.Gravity;
                    xValue = acceleration.X;
                    yValue = acceleration.Y;
                    zValue = acceleration.Z;
                    isData = true;
                }
            }

            if (isRunning)
            {
                PerformSelector(new ObjCRuntime.Selector("Update"), null, UpdateInterval);
            }
        }
Exemple #4
0
 private static Vector3 CmAccelerationToVector3(CMAcceleration acceleration)
 {
     return(InputManager.G * new Vector3((float)acceleration.X, (float)acceleration.Z, -(float)acceleration.Y));
 }
		public void AccelerometerDidChange (CMAcceleration acceleration)
		{
			float filteringFactor = 0.5f;
			accelerometer.X = (float)acceleration.X * filteringFactor + accelerometer.X * (1f - filteringFactor);
			accelerometer.Y = (float)acceleration.Y * filteringFactor + accelerometer.Y * (1f - filteringFactor);
			accelerometer.Z = (float)acceleration.Z * filteringFactor + accelerometer.Z * (1f - filteringFactor);

			if (accelerometer.X > 0) {
				orientation = (float)(accelerometer.Y * 1.3f);
			} else {
				orientation = (float)(-accelerometer.Y * 1.3f);
			}
		}
Exemple #6
0
 private static Vector3 CmAccelerationToVector3(CMAcceleration acceleration)
 {
     return G * new Vector3((float)acceleration.X, (float)acceleration.Z, -(float)acceleration.Y);
 }