Animated Mouse Cursor

No coding posts this time around, just had a question regarding LibGDX and custom mouse cursors.

For those who’ve messed with LibGDX for a time, is it possible to use an animated sprite as a mouse cursor without having to use pixmaps? If not, is it even possible to animate pixmaps converted from a spritesheet? Or rather, is it possible to animate pixmaps at all?

How did you go about doing this?

I’m a bit stuck on the theory of it all and couldn’t find much information about this specific topic by googling it. Thought I’d get it directly from the source.

Appreciate the help!

You could have a class that is sort of like the Animation class. You have a variable in there keeping track of time and when it reaches a certain amount of time, you would then change the cursor image by getting a Pixmap from an array of pixmaps, then start the timer over again. I would be happy to help you out and elaborate a little more as well.

Again, I appreciate the help!

With regards to the pixmap array, I like that idea!
My only concern is if that would that mean that I would save each frame of an animation separately, instead of having a sort of “PixmapRegion” that it shuffles through on a single pixmap, like in the Animation class.

…Is that a thing?

Yep, each frame of the animation would have to be separate. Then, I would make a Pixmap array and fill it with a couple cursor frames. Here, my array of Pixmaps is called frames.


... // Timer stuff

if(index == frames.length) // Reset the index if it reaches the end of the array
	index = 0;
Gdx.input.setCursorImage(frames[index++], #, #); // Set the cursor image to index then increment by 1