Hello,
Recently, I've been having an issue with custom cursors and love.graphics.scale. I have a custom pointer that, while the scale is set to 1, the image of the pointer and the actual cursor (hidden) match up fine. However, when I scale the window and all of the graphics using love.graphics.scale, the custom pointer image gets bigger as it should, but it no longer matches up with the real cursor's position. It ends up jumping off-screen, and I have to move the real cursor to get the custom cursor back on-screen. I also noticed that the bigger the window scale gets, the faster the custom pointer moves. The one upside to this is that the custom cursor still snaps to the 1 pixel grid. I tried scaling the cursor separately, and while I was able to get the two to match up again, the custom cursor moved independently of the pixel grid. How can I get them to match up AND stick within the 1 pixel grid?
Sorry I dragged this out so long, hopefully I didn't waste too much of your time
[SOLVED] Custom Cursors and Window Scaling
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
[SOLVED] Custom Cursors and Window Scaling
Last edited by Zorochase on Fri Aug 18, 2017 3:38 am, edited 1 time in total.
"I am a tomato. My favorite food is tomatoes. Tomatoes are the best. I eat them everyday. I love to hear them scream."
Re: Custom Cursors and Window Scaling
You need to also scale the cursor position. For example, say your original resolution is 10x10 pixels. At a scale of 1 the ratio of the system cursor to the game cursor is 1:1. Now let's assume you scale your window to 20x20. The scale is now 2:1, that is, for every 2 pixels the system cursor moves, your game cursor needs to move 1 pixel.
Pseudo code:
This works because whilst your final output to the screen is scaled, all of your drawing is still being done at the original resolution.
Pseudo code:
Code: Select all
cursorPosition = mousePosition / windowScale
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
Re: Custom Cursors and Window Scaling
Looks like you were right, I've got it now. Thank you!Lafolie wrote: ↑Fri Aug 18, 2017 12:00 am You need to also scale the cursor position. For example, say your original resolution is 10x10 pixels. At a scale of 1 the ratio of the system cursor to the game cursor is 1:1. Now let's assume you scale your window to 20x20. The scale is now 2:1, that is, for every 2 pixels the system cursor moves, your game cursor needs to move 1 pixel.
Pseudo code:This works because whilst your final output to the screen is scaled, all of your drawing is still being done at the original resolution.Code: Select all
cursorPosition = mousePosition / windowScale
"I am a tomato. My favorite food is tomatoes. Tomatoes are the best. I eat them everyday. I love to hear them scream."
Who is online
Users browsing this forum: Bing [Bot] and 4 guests