Hey there! I have run into a particularly annoying problem, I feel like this is completely possible and easy, but I have had such difficulty with this.
So when I am in the smallest resolution I can get, move dialog item to mouse position in the UI X and Y work perfectly, however, if I go into any other aspect ratio or resolution, the dialog item detaches itself from the mouse and moves at a different rate across the screen. I was wondering if anyone has an example where they successfully moved dialog images on their mouse across the UI without any problems.
The solution I came up with of asking the player to press on 3 or 4 places on the screen to "calibrate" a correction feels over complicated and awkward. Any help or references would be much appreciated.
Okay, thanks, looks like I am actually making some surprising progress however. I made an array of 30 and a second array of 30 buttons doing corrections upon the x axis and y axis, moving at a difference of x 0.03 then being converted to integers for a much more accurate result, you can see in this image the array of buttons, and one of the buttons on each resolution follows the mouse pretty close to perfectly :D
The black lines are at every supposed to be 100 (so I can visualize), and the green line intersection point is where the dialog items are tracking the original value from, each blue button is moved out by being multiplied by 1 + (0.04) more than the last, the stream of numbers are spitting out X and Y values of the scaled 1600 by 1200 space that starcraft 2 measures and scales its screens on, this particular resolution requires a correction of x1.32 more to the right to stay on the mouse, i know this because if follows the 8th button ( 1 + ((8)*0.04) = 1.32). With a button on the right side of the screen for the player to start the game, I can sneakaly grab the correction without them even knowing :D (I will probably communicate that it is calibrating the screen so that if they change their resolution mid game they can go back and re-calibrate).
I think it is pretty nifty what about you? I was initially just multiplying and dividing with integers for corrections, but I realized that I could do the math with real numbers, then convert to integer to get a much more precise calculation.
Just a random thought that occurred while reading this. I don't know what your map is, so this may not be a possibility, but what about hiding the players real mouse and giving them a fake one based on the same calculations you're using for the image itself. They won't know its a fake mouse, they'll just think its the real thing.
that same thought occurred to me when thinking of changing the mouse image to something else so that when a player grabs something the mouse will "animate" to grabbing something. So yes, it is a possibility, but I would only do it mid drag and not on the click because this system, while pretty dam close, is not perfect. (also battle.net delay would make it lag behind)
Also, upon further testing and screwing with all the resolutions available (even sideways and upside down resolutions that made my head hurt) I could not get the Y value to be all screwy, so I removed the second row that was accounting for any possible y value differences.
Very interesting Cacho56, funnily enough I had also thought of this solution as well, but I felt that it was not as smooth as I wanted the movement to be, it would not have fit my aesthetic that I was shooting for.
Thank you all for your responses, from what I have gathered, you cannot directly reference the resolution of a player without them doing something like clicking their mouse at a specified point (in some methods), and then comparing the mouse position to the "actual position" somehow. Or doing what Cacho56 did which avoids the whole screen resolution correction issue.
I believe I found a solution for my map already in the post I made above, but now I know that it is 100% necessary, I can move on with the project :) Thanks for the replies!
Hey there! I have run into a particularly annoying problem, I feel like this is completely possible and easy, but I have had such difficulty with this.
So when I am in the smallest resolution I can get, move dialog item to mouse position in the UI X and Y work perfectly, however, if I go into any other aspect ratio or resolution, the dialog item detaches itself from the mouse and moves at a different rate across the screen. I was wondering if anyone has an example where they successfully moved dialog images on their mouse across the UI without any problems.
The solution I came up with of asking the player to press on 3 or 4 places on the screen to "calibrate" a correction feels over complicated and awkward. Any help or references would be much appreciated.
@joecab: Go
I don't believe there is any other solution than to have a person calibrate. None done any other way that I have ever seen.
@JacktheArcher: Go
Okay, thanks, looks like I am actually making some surprising progress however. I made an array of 30 and a second array of 30 buttons doing corrections upon the x axis and y axis, moving at a difference of x 0.03 then being converted to integers for a much more accurate result, you can see in this image the array of buttons, and one of the buttons on each resolution follows the mouse pretty close to perfectly :D
The black lines are at every supposed to be 100 (so I can visualize), and the green line intersection point is where the dialog items are tracking the original value from, each blue button is moved out by being multiplied by 1 + (0.04) more than the last, the stream of numbers are spitting out X and Y values of the scaled 1600 by 1200 space that starcraft 2 measures and scales its screens on, this particular resolution requires a correction of x1.32 more to the right to stay on the mouse, i know this because if follows the 8th button ( 1 + ((8)*0.04) = 1.32). With a button on the right side of the screen for the player to start the game, I can sneakaly grab the correction without them even knowing :D (I will probably communicate that it is calibrating the screen so that if they change their resolution mid game they can go back and re-calibrate).
I think it is pretty nifty what about you? I was initially just multiplying and dividing with integers for corrections, but I realized that I could do the math with real numbers, then convert to integer to get a much more precise calculation.
Just a random thought that occurred while reading this. I don't know what your map is, so this may not be a possibility, but what about hiding the players real mouse and giving them a fake one based on the same calculations you're using for the image itself. They won't know its a fake mouse, they'll just think its the real thing.
@MaskedImposter: Go
that same thought occurred to me when thinking of changing the mouse image to something else so that when a player grabs something the mouse will "animate" to grabbing something. So yes, it is a possibility, but I would only do it mid drag and not on the click because this system, while pretty dam close, is not perfect. (also battle.net delay would make it lag behind)
Also, upon further testing and screwing with all the resolutions available (even sideways and upside down resolutions that made my head hurt) I could not get the Y value to be all screwy, so I removed the second row that was accounting for any possible y value differences.
You can try this method. It's not exactly what you want, but it might work as an startup for your function...
It's a matrix of buttons. Once a button is pressed, if the image is inside of it, it's selected and moved to the next button pressed location.
Check out my kitbashes! Custom Campaign Initiative: Lots of great Custom Campaigns!! Check out and Support!!
Very interesting Cacho56, funnily enough I had also thought of this solution as well, but I felt that it was not as smooth as I wanted the movement to be, it would not have fit my aesthetic that I was shooting for.
Thank you all for your responses, from what I have gathered, you cannot directly reference the resolution of a player without them doing something like clicking their mouse at a specified point (in some methods), and then comparing the mouse position to the "actual position" somehow. Or doing what Cacho56 did which avoids the whole screen resolution correction issue.
I believe I found a solution for my map already in the post I made above, but now I know that it is 100% necessary, I can move on with the project :) Thanks for the replies!