Getting X and Y on the screen.

This forum is currently in read-only mode.
From the Asset Store
Is a circular loading screen with code ready to use. No Animation.
  • Hello, i realized that when i get the X and Y of the mouse, it gives the point on the screen instead of the points in the game.

    So i want to get the X and Y of an object by its points on the screen, is it possible?

    The reason is:

    I am trying to make an auto-target, so when i press the button X, the mouse cursor go to a target.

    I can�t make that by picking the X and Y of an object because the are different types of valors.

  • The built in expressions MouseX and MouseY give coordinates in the game.

  • I am trying to make an auto-target, so when i press the button X, the mouse cursor go to a target.

    You can't set the position of the mouse, if that's what you mean. The mouse sets the position of the mouse.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • [quote:67fqouzq]You can't set the position of the mouse, if that's what you mean. The mouse sets the position of the mouse.

    But in the actions on events sheet there?s a command to "Set mouse X" and "Set mouse Y" in the "MouseKeyboard" object Oo

  • Whaaaa...

    I have never noticed that action. Very strange! I learned something new today.

    Anyway, it appears that it sets the coordinates according to your desktop and not according to your the game window. So I don't know of a really good method for using that the way you need it.

  • You can use the Window object to get the position of the window and position the mouse accordingly.

    Example

    This positions the mouse to a randomly picked box. You'll probably have to add some things to account for screen scrolling -- if you need it -- but it shouldn't be to difficult.

  • Oh, thanks linkman, but i test on my project and it�s didn�t work well...

    What�s the difference between getting the ClientX and X of the window?

    Do you think there�s a different way to make that?

  • ClientX returns the position of your game frame relative to the screen while the X position of the window is the position of the window from the top left including the title bar and border.

    I suggest that you post a CAP file that we can take a look out so we can help with your problem.

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