How do I detect mouse movement.

0 favourites
  • 3 posts
From the Asset Store
Total customisation of the input! You can combine inputs from all peripherals. Make your game accessible for everyone!
  • I want to know if there's a way to detect mouse Movement. I don't mean mouse position, I need to detect the direction and/or velocity of the mouse's movement (This could be in the form of vectors). This would have to be capable of detecting that the mouse is being moved in a direction even if the mouse cursor itself is already at the corner of the screen.

    Thanks.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can save the mouse position to some variables at the end of every frame. Then you could compare the previous frame’s mouse position with the current one. If they’re different, the mouse moved. You can get the velocity of the mouse by subtracting the previous position from the current, getting the magnitude of that and dividing but the length of a frame.

    Having it work when the cursor is already in the corner of the screen isn’t possible with the mouse api exposed by browsers.

  • You can save the mouse position to some variables at the end of every frame. Then you could compare the previous frame’s mouse position with the current one. If they’re different, the mouse moved. You can get the velocity of the mouse by subtracting the previous position from the current, getting the magnitude of that and dividing but the length of a frame.

    Having it work when the cursor is already in the corner of the screen isn’t possible with the mouse api exposed by browsers.

    wow thanky ou !

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