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/LWJGL3 back-ends.
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.
Pages 218
- Home
- 2D Animation
- 2D Particle Editor
- 2D ParticleEffects
- 3D animations and skinning
- 3D Graphics
- 3D Particle Effects
- a note from the translation
- A Simple Game
- Accelerometer
- Actions
- Admob in libgdx
- Airpush in Libgdx
- APK Expansions support
- Artificial Intelligence
- Asset manager
- Audio
- Back and menu key catching
- Bitmap fonts
- Box2d
- Build Infrastructure Setup
- Building libgdx from source
- Building Natives
- Building the Bullet wrapper
- Bullet physics
- Bullet Wrapper Contact callbacks
- Bullet Wrapper Custom classes
- Bullet Wrapper Debugging
- Bullet Wrapper Setup
- Bullet Wrapper Using models
- Bullet Wrapper Using the wrapper
- Bullet Wrapper Contact callbacks
- Bullet Wrapper Custom classes
- Bullet Wrapper Debugging
- Bullet Wrapper Setup
- Bullet Wrapper Using models
- Bullet Wrapper Using the wrapper
- Bundling a JRE
- Circles, planes, rays, etc.
- Clearing the screen
- Clipping, with the use of scissorstack
- Collections
- Color Markup Language
- Community & Support
- Compass
- Configuration & querying
- Configuration & Querying
- Configuration & Querying
- Continuous & non continuous rendering
- Continuous & Non Continuous Rendering
- Contributing
- Controllers
- Coordinate systems
- Creating a Separate Assets Project in Eclipse
- Creating and texturing 3d models in blender for libgdx
- Cursor visibility & catching
- Cursor Visibility & Catching
- Decals
- Dependency management with Gradle
- Deploying as an Applet
- Deploying your application
- Distance field fonts
- Event handling
- Excelsior JET and libGDX
- Extending the simple game
- External tutorials
- File handling
- File module
- Frame buffer objects
- Games built with libgdx
- Gdx audio
- gdx dialogs
- gdx facebook
- Gdx freetype
- gdx kiwi
- gdx lml
- gdx pay
- Gesture detection
- Getting Help
- Getting ready for #libGDXJAM
- Goals & Features
- Google Mobile Ads in Libgdx (replaces deprecated AdMob)
- Google Play Games Services in LibGDX
- Google Summer of Code 2014
- Gradle and Eclipse
- Gradle and IntelliJ IDEA
- Gradle and NetBeans
- Gradle on the Commandline
- Graphics
- Graphics module
- GWT notes
- Gwt super dev mode
- Gyroscope
- Hello world
- Hiero
- HTML5 Backend and GWT Specifics
- ImGui
- Importing Blender models in LibGDX
- Improving workflow with Gradle
- Input handling
- Integrating libgdx and the device camera
- Intel RealSense Integration
- Interfacing with platform specific code
- Internationalization and Localization
- Interpolation
- Introduction
- Ios notes
- Issue Tracker
- jnigen
- libgdx utils
- libgdx utils box2d
- Local LibGDX package use with GWT
- Logging
- Managing your assets
- Manual project setup
- Material and environment
- Math utilities
- Maven integration
- Memory management
- Mesh, color & texture
- Meshes
- ModelBatch
- ModelBuilder, MeshBuilder and MeshPartBuilder
- ModelCache
- Models
- Modules overview
- More Info
- Mouse, touch & keyboard
- Mouse, Touch and Keyboard
- My First Triangle (Example)
- Networking
- Nextpeer in libgdx
- Ninepatches
- On screen keyboard
- Opengl es support
- Orthographic camera
- Overlap2D
- Overlap2D survival guide for #libGDXJAM
- Packing atlases at runtime
- Packing atlases offline
- Path Editor
- Path interface and Splines
- Physics
- Pixmaps
- Playing pcm audio
- Pollfish in libgdx
- Polling
- Preferences
- Profiling
- ProGuard DexGuard and libGDX
- Project Setup Gradle
- Project setup, running & debugging
- Projection, viewport, & camera
- Querying
- Querying & configuring graphics (monitors, display modes, vsync)
- Querying & configuring graphics (monitors, display modes, vsync)
- Quick start
- Reading and writing JSON
- Reading and writing XML
- Recording pcm audio
- Reflection
- Release Process
- Rendering shapes
- Robovm notes
- Running Demos
- Running demos & tests
- Running Tests
- Saved game serialization
- Scene2d
- Scene2d.ui
- Screen & viewport
- Setting Up Google In App Billing
- Setting up your Development Environment (Eclipse, Intellij IDEA, NetBeans)
- Shaders
- Simple Car Racing Game
- Simple text input
- Skin
- Skin Properties
- Sound effects
- Spritebatch, textureregions, and sprite
- Spritebatch, Textureregions, and Sprites
- Starter classes and configuration
- Streaming music
- Swarm in libgdx
- Table
- Table Of Contents
- Taking a Screenshot
- TextButton
- Texture Compression
- Texture packer
- Textures & textureregions
- Textures & TextureRegions
- Textures, textureregion and spritebatch
- The application framework
- The life cycle
- Third Party Extension Support
- Third Party Extensions
- Third party services
- Threading
- Tile maps
- Universal Tween Engine
- Updating LibGDX
- Using libgdx with android studio
- Using libgdx with Clojure
- Using libgdx with intellij idea
- Using libGDX with Kotlin
- Using libGDX with other JVM languages
- Using libgdx with Python
- Using libgdx with Scala
- Using textureatlases
- Using with Groovy
- Vectors, matrices, quaternions
- Vibrator
- Video tutorials
- Viewports
- VisRuntime
- VisUI
- Wiki Style Guide
Table of Contents
Developer's Guide
The Application Framework
A Simple Game
Input Handling
Graphics
- 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
- Using TextureAtlases
- Pixmaps
- Packing Atlases Offline
- Packing Atlases at Runtime
- Texture Compression
- 2D ParticleEffects
- Tile Maps
- scene2d
- scene2d.ui
- ImGui
Internationalization and Localization
Math Utilities
- Math Utilities
- Interpolation
- Vectors, Matrices, Quaternions
- Circles, Planes, Rays, etc.
- Path Interface and Splines
- Bounding Volumes ??
- Intersection & Overlap Testing ??
Extensions
- Artificial Intelligence
- gdx-freetype
- gdx-pay: cross-platform In-App-Purchasing API
- Physics
Using libGDX With Other JVM Languages
Third Party Services
Articles
- Getting Help
- External Tutorials
- Bundling a JRE
- Deploying as an Applet
- HTML5 Backend and GWT Specifics
- Getting ready for #libGDXJAM
- Coordinate systems
- Updating Your libGDX Version
- Adding Extensions and 3rd Party Libraries
- Publishing Your Own Extensions Via the Setup Application
- Improving Your Gradle Workflow
- Creating Asset Project in Eclipse