0 Favourites

how to set the mouse cursor position in in-game coordinates

This forum is currently in read-only mode.
  • setting the mouse cursor where you want it isn't as simple as setting mousex and mousey with mouse/keyboard. those actions set the cursor to screen coordinates, meaning the coordinates on your monitor, which have nothing to do with the game.

    to set the mouse coordinates to a spot in your game, you need to take into account where the window is on the screen, how far into your layout you are scrolled, and how zoomed in you are. there is a formula you can use, and it's demonstrated in the following cap:

    http://dl.dropbox.com/u/1013446/mouseset.cap

    when you run the cap, mousewheel zooms in and out, and since your mouse is hijacked and you can't reach the close button, hit escape to exit

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • Very nice. To help me understand this a little better, would you mind me asking the difference between "Window.ClientX" as apposed to "Window.X"? I noticed the results were a hair off when I switched them, but it was pretty much the same.

  • Very nice. To help me understand this a little better, would you mind me asking the difference between "Window.ClientX" as apposed to "Window.X"? I noticed the results were a hair off when I switched them, but it was pretty much the same.

    Window.X gets the position of the window including the border and title bar, while Window.ClientX gets the position of the content of the window, which excludes the border.

  • Window.X gets the position of the window including the border and title bar, while Window.ClientX gets the position of the content of the window, which excludes the border.

    I see, thanks!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)