forked from libgdx/libgdx
-
Notifications
You must be signed in to change notification settings - Fork 0
Compass
Davis Silverman edited this page Sep 18, 2013
·
3 revisions
Some Android phones have an integrated magnetic field sensor that provides information on how the device is oriented with respect to the magnetic north pole.
Querying whether the compass is available works as follows:
boolean compassAvail = Gdx.input.isPeripheralAvailable(Peripheral.Compass);
Once you determined that the compass is indeed available, you can poll its state:
float azimuth = Gdx.input.getAzimuth();
float pitch = Gdx.input.getPitch();
float roll = Gdx.input.getRoll();
The angles are given in degrees. Here's the interpretation of these values:
- The azimuth is the angle of the device's orientation around the z-axis. The positive z-axis points towards the earths center.
- The pitch is the angle of the device's orientation around the x-axis. The positive x-axis roughly points to the west and is orthogonal to the z- and y-axis.
- The roll is the angle of the device's orientation around the y-axis. The positive y-axis points toward the magnetic north pole of the earth while remaining orthogonal to the other two axes.
Here's an illustration of the axis relative to the earth.
-
Developer's Guide
- Introduction
- Goals & Features
- Community & Support
- Contributing
- Games Built with Libgdx
- Prerequisites
- Project Setup, Running & Debugging
- Third Party Services
- Working from Source
- Using libgdx with other JVM languages
- The Application Framework
- A Simple Game
- File Handling
- Preferences
- Input Handling
- Memory Management
- Audio
-
Graphics
- Configuration & Querying Graphics ??
- Fullscreen & VSync
- Continuous & Non-Continuous Rendering
- Clearing the Screen
- OpenGL ES Support * Configuration & Querying OpenGL ?? * Direct Access ?? * Utility Classes * Rendering Shapes * Textures & TextureRegions * Meshes * Shaders * Frame Buffer Objects
- 2D Graphics * SpriteBatch, TextureRegions, and Sprite * Clipping, with the use of ScissorStack * Orthographic camera * Mapping Touch Coordinates ?? * NinePatches * Bitmap Fonts * Distance field fonts * Using TextureAtlases * Pixmaps * Packing Atlases Offline * Packing Atlases at Runtime * 2D Particle Effects * Tile Maps * scene2d * scene2d.ui * Skin
- 3D Graphics ?? * Quick Start * 3D animations and skinning * Importing Blender models in LibGDX * Perspective Camera ?? * Picking ??
- Managing Your Assets
- Utilities
-
Math Utilities
- Interpolation
- Vectors, Matrices, Quaternions
- Circles, Planes, Rays, etc.
- Bounding Volumes ??
- Intersection & Overlap Testing ??
- Physics
- Tools
- Extensions
- gdx-audio ??
- gdx-freetype
- Deploying your Application
- Building Libgdx ??
- Articles
- Deprecated (May be outdated)
- The Application Framework
- The Application Life-cycle ??
- Modules Overview
- File Module
- Graphics Module
- Asset Manager
- Tutorials
- Video Tutorials
- Beginner * Hello World * My First Triangle * Mesh, Color & Texture * Projection, Viewport, & Camera * Creating and texturing 3d models in Blender for Libgdx
- Intermediate * Actions
- Misc * AdMob in Libgdx * Integrating Libgdx and the Device camera * String Builder ??
- The Application Framework