Is it possible to adjust the opacity of cursor in Love2D?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 2
- Joined: Sun Jan 06, 2019 6:30 pm
Is it possible to adjust the opacity of cursor in Love2D?
So, I am using a custom cursor that I made. I wonder if there is way to lower the opacity of my custom cursor.
Re: Is it possible to adjust the opacity of cursor in Love2D?
There's no way to dynamically change the opacity of the cursor. You can load the cursor image as ImageData and then change the alpha value for all pixels. Then you use the ImageData as argument for love.mouse.newCursor().
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
"If each mistake being made is a new one, then progress is being made."
- zorg
- Party member
- Posts: 3465
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Is it possible to adjust the opacity of cursor in Love2D?
(Expanding the previous idea, you could create multiple imagedata, change the alpha values differently for each, then each frame, set a different cursor image; but it might be very resource intensive (or it might not be, check the wiki for warnings or just test it yourself ))
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Re: Is it possible to adjust the opacity of cursor in Love2D?
(Image):replacePixels might work for updating the image. I haven't tested it, so caveat emptor.
-
- Prole
- Posts: 2
- Joined: Sun Jan 06, 2019 6:30 pm
Re: Is it possible to adjust the opacity of cursor in Love2D?
Thanks to ReFreezed, zorg, and pgimeno, I found a solution to how I can change my cursor's opacity.
This is to anyone who wants to do the same:
The part where I divide "a" by 2 is defining how transparent it is. You can increase the number that is being divided by "a" to make it even more transparent.
This is to anyone who wants to do the same:
Code: Select all
cursorData = love.image.newImageData("path/to/image")
cursorData:mapPixel(function(x, y, r, g, b, a) return r, g, b, a/2 end)
cursor = love.mouse.newCursor(cursorData, 0, 0)
love.mouse.setCursor(cursor)
Who is online
Users browsing this forum: Bing [Bot] and 5 guests