-
Notifications
You must be signed in to change notification settings - Fork 0
Input handling
Different platforms have different input facilities. On the desktop users can talk to your application via the keyboard and a mouse. The same is true for browser based games. On Android, the mouse is replaced with a (capacitive) touch screen, and a hardware keyboard is often missing. All (compatible) Android devices also feature an accelerometer and sometimes even a compass (magnetic field sensor).
Libgdx abstract all these different input devices. Mouse and touch screens are treated as being the same, with mice lacking multi-touch support (they will only report a single "finger") and touch-screens lacking button support (they will only report "left button" presses).
Depending on the input device, one can either poll the state of a device periodically, or register a listener that will receive input events in chronological order. The former is sufficient for many arcade games, e.g. analogue stick controls, the later is necessary if UI elements such as buttons are involved, as these rely on event sequences such as touch down/touch up.
All of the input facilities are accessed via the Input module.
// Check if the A key is pressed
boolean isPressed = Gdx.input.isKeyPressed(Keys.A);
- Wiki Style Guide
-
Developer's Guide
- Introduction
- Setting up your Development Environment (Eclipse, Android Studio, 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
- Querying & configuring graphics (monitors, display modes, vsync)
- Continuous & Non-Continuous Rendering
- Clearing the Screen
- Taking 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 * Texture Compression * 2D ParticleEffects * Tile Maps * scene2d * scene2d.ui * Table * Skin
- 3D Graphics * Quick Start * Models * Material and Environment * ModelBatch * ModelCache * 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
- gdx-freetype
- gdx-pay: cross-platform In-App-Purchasing API
-
Physics
* Box2D
* Bullet Physics * Setup * Using the Wrapper * Using Models * Contact Callbacks * Custom Classes * Debugging
- Using libGDX With Other JVM Languages
- Third Party Extensions
- Third Party Services
- Articles