-
Notifications
You must be signed in to change notification settings - Fork 0
Cursor visibility & catching
For some games like first person shooters, it is often necessary to catch the cursor so it stays in the center of the screen, and only use position deltas to rotate the camera. Other times we might want to position the cursor manually. Both things can be done as follows:
Gdx.input.setCursorCatched(true);
Gdx.input.setCursorPosition(x, y);
Note that catching the cursor only works reliably in the Lwjgl back-end. The Jogl backend uses the AWT/Swing Robot class which has a few quirks.
Cursor catching and positioning is only available on the desktop.
Similarly, changing the cursor image is available on the desktop and on gwt if the browser supports the "cursor:url()" syntax and also supports the png format as cursor. It can be done as follows:
Note: You Should dispose the cursor if you don't need it anymore
Cursor customCursor = Gdx.graphics.newCursor(new Pixmap(Gdx.files.internal("cursor.png")), hotspotX, hotspotY);
Gdx.graphics.setCursor(customCursor);
You can also change the cursor to a system cursor, this only works in the LWJGL3 backend and in the GWT backend. It can be done as follows:
Gdx.graphics.setSystemCursor(SystemCursor.Crosshair);
Supported system cursors are the
-
Arrow
-
Ibeam
-
Crosshair
-
Hand
-
HorizontalResize
-
VerticalResize
cursors.
- 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