This class handles the gyroscope. You need to initialize in the main class of the game. Once the init() function is called, you are ready to read the gyroscope anywhere in your program, because it's a static class. No instantiation is necesary.

You will need the EulerGyroscope Class, google it.

package controls
{
	import de.ketzler.nativeextension.EulerGyroscope;
	import de.ketzler.nativeextension.EulerGyroscopeEvent;
 
	import flash.events.AccelerometerEvent;
	import flash.sensors.Accelerometer;
 
	public class CustomFlxGyroscope
	{
		public static var angleX:Number = 0;
		public static var angleY:Number = 0;
		public static var angleZ:Number = 0;
 
		public function CustomFlxGyroscope()
		{
			super();
 
		}
 
		public static function init():void
		{
			if(Accelerometer.isSupported)
			{
				var gyro:Accelerometer = new Accelerometer();
				gyro.addEventListener(AccelerometerEvent.UPDATE, handleUpdate);
			}
		}
 
		private static function handleUpdate(event:AccelerometerEvent) : void {
			angleX = event.accelerationX;
			angleY = event.accelerationY;
			angleZ = event.accelerationZ;
		}
	}
}
  tutorials/ios_gyroscope_handler.txt · Last modified: 2013/05/29 22:41 by 186.23.217.125
 
Powered by DokuWiki