Gyroscope is an extension that provides access to a device’s native gyroscope sensor.
Some features:
- Provides access to native gyroscope sensor functionality.
- Works across iOS and Android with the same code
- Sample project code and ASDocs reference
Sample
/** * __ __ __ * ____/ /_ ____/ /______ _ ___ / /_ * / __ / / ___/ __/ ___/ / __ `/ __/ * / /_/ / (__ ) / / / / / /_/ / / * \__,_/_/____/_/ /_/ /_/\__, /_/ * / / * \/ * http://distriqt.com * * This is a test application for the distriqt extension * * @author Michael Archbold & Shane Korin * */ package { import com.distriqt.extension.gyroscope.Gyroscope; import com.distriqt.extension.gyroscope.events.GyroscopeEvent; import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageScaleMode; import flash.events.Event; import flash.events.MouseEvent; import flash.text.TextField; import flash.text.TextFormat; /** * Sample application for using the Gyroscope Native Extension * * @author Michael Archbold */ public class TestGyroscope extends Sprite { /** * Class constructor */ public function TestGyroscope() { super(); create(); init(); } // // VARIABLES // private var _text : TextField; // // INITIALISATION // private function create( ):void { stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; var tf:TextFormat = new TextFormat(); tf.size = 24; _text = new TextField(); _text.defaultTextFormat = tf; addChild( _text ); stage.addEventListener( Event.RESIZE, stage_resizeHandler, false, 0, true ); stage.addEventListener( MouseEvent.CLICK, mouseClickHandler, false, 0, true ); addEventListener( Event.ACTIVATE, activateHandler, false, 0, true ); addEventListener( Event.DEACTIVATE, deactivateHandler, false, 0, true ); } private function init( ):void { try { Gyroscope.init( "your_dev_key" ); message( "Gyroscope Supported: "+ String(Gyroscope.isSupported) ); message( "Gyroscope Version: " + Gyroscope.service.version ); // // Add test inits here // Gyroscope.service.addEventListener( GyroscopeEvent.UPDATE, gyro_updateHandler ); } catch (e:Error) { trace(" >> " +e); } } // // FUNCTIONALITY // private function message( str:String ):void { trace( str ); _text.appendText(str+"\n"); } // // EVENT HANDLERS // private function stage_resizeHandler( event:Event ):void { _text.width = stage.stageWidth; _text.height = stage.stageHeight - 100; } private function mouseClickHandler( event:MouseEvent ):void { // // Do something when user clicks screen? // message( "Starting Gyroscope service..." ); Gyroscope.service.register(); } // // COMPASS NOTIFICATION HANDLERS // private function gyro_updateHandler(event:GyroscopeEvent):void { message( "Update : " + event.x + ", " + event.y + " - " + event.z ); } private function activateHandler( event:Event ):void { } private function deactivateHandler( event:Event ):void { Gyroscope.service.unregister(); message("Stopping Gyroscope service due to deactivation."); trace( "deactivateHandler() "); } } }
RT @as3gamegears http://t.co/9S4YARGH #as3 #flash #gamedev: New: Gyroscope (extension that provides access to a… http://t.co/snbcFNXC