-
Notifications
You must be signed in to change notification settings - Fork 0
Configuration & querying
Sometimes it is necessary to know which input devices are supported. It is also often the case that your game does not need the full range of input devices supported, e.g. you might not need the accelerometer or compass. It is good practice to disable those input devices in that case to preserve battery on Android. The following sections will show you how to perform these actions.
Configuring input devices only makes sense on Android at the moment. The AndroidApplicationConfiguration class has a couple of public fields you can set before you hand it of to the AndroidApplication.initialize()
method.
Assuming our game doesn't need the accelerometer and compass, we can disable this input devices as follows:
public class MyGameActivity extends AndroidApplication {
@Override
public void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
config.useAccelerometer = false;
config.useCompass = false;
initialize(new MyGame(), config);
}
}
Both the accelerometer and the compass are enabled by default. The above code disables them and will thus preserve some precious battery.
To check whether a specific input device is available on the platform the application currently runs, you can use the Input.isPeripheralAvailable()
method.
boolean hardwareKeyboard = Gdx.input.isPeripheralAvailable(Peripheral.HardwareKeyboard);
boolean multiTouch = Gdx.input.isPeripheralAvailable(Peripheral.MultitouchScreen);
Please refer to the Peripheral enumeration to see the rest of the available constants.
Note that only a few Android devices have a hardware keyboard. Even if the keyboard is physically present, the user might not have slid it out. The method shown above will return false in this case.
-
Developer's Guide
- Introduction
- Setting up your Development Environment (Eclipse, Intellij IDEA, NetBeans)
- Creating, Running, Debugging and Packaging your Project
- Working from Source
- The Application Framework
- A Simple Game
- File Handling
- Networking
- Preferences
- Input Handling
- Memory Management
- Audio
-
Graphics
- Configuration & Querying Graphics ??
- Fullscreen & VSync
- Continuous & Non-Continuous Rendering
- Clearing the Screen
- Take a Screenshot
- Profiling
- Viewports
- OpenGL ES Support * Configuration & Querying OpenGL ?? * Direct Access ?? * Utility Classes * Rendering Shapes * Textures & TextureRegions * Meshes * Shaders * Frame Buffer Objects
- 2D Graphics * SpriteBatch, TextureRegions, and Sprites * 2D Animation * Clipping, with the use of ScissorStack * Orthographic camera * Mapping Touch Coordinates ?? * NinePatches * Bitmap Fonts * Distance field fonts * Color Markup Language * Using TextureAtlases * Pixmaps * Packing Atlases Offline * Packing Atlases at Runtime * 2D Particle Effects * Tile Maps * scene2d * scene2d.ui * Table * Skin
- 3D Graphics * Quick Start * Models * Material and environment * ModelBatch * ModelBuilder, MeshBuilder and MeshPartBuilder * 3D animations and skinning * Importing Blender models in LibGDX * 3D Particle Effects * Perspective Camera ?? * Picking ??
- Managing Your Assets
- Internationalization and Localization
- Utilities
-
Math Utilities
- Interpolation
- Vectors, Matrices, Quaternions
- Circles, Planes, Rays, etc.
- Path interface & Splines
- Bounding Volumes ??
- Intersection & Overlap Testing ??
- Tools
- Extensions
- Artificial Intelligence * Message Handling * State Machine
- gdx-freetype
-
Physics
* Box2D
* Bullet Physics * [Setup](../Bullet Wrapper - Setup) * [Using the wrapper](../Bullet Wrapper - Using the wrapper) * [Using models](../Bullet Wrapper - Using models) * [Contact callbacks](../Bullet Wrapper - Contact callbacks) * [Custom classes](../Bullet Wrapper - Custom classes) * [Debugging](../Bullet Wrapper - Debugging)
- Using libgdx with other JVM languages
- Third Party Services
- Articles