How to determine if the mouse is outside the rendering area?

0 favourites
  • 4 posts
From the Asset Store
Total customisation of the input! You can combine inputs from all peripherals. Make your game accessible for everyone!
  • I'm having difficulty finding a way to do this. I want the screen to scroll when the mouse is near the edge of the window, but stop if it goes past the edge of the window (the rendering area, technically). In all the tests I've done, it just keeps scrolling.

    Anyone know of a way to accomplish this? I've tried checking the mouse values but they stop updating outside the window. Checking if the mouse is over a fullscreen sprite doesn't work either for the same reason.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Just an idea, but in the event that you are not running full screen (allowing your mouse to get off the window), try having a couple pixels of dead zone right around the edge that does not scroll. If you are full screen, I think you would not want this dead zone, but there are conditions to take care of that.

  • The problem with that method is it's inconsistent based upon the speed of the mouse and where it happens to be when the measurements of its position are checked - if the mouse moves quickly, it's a large gap.

  • How about only scrolling when:

    ViewportLeft("MouseLayer") < Mouse.X < ViewportRight("MouseLayer")

    ViewportTop("MouseLayer") < Mouse.Y < ViewportBottom("MouseLayer")

    ?

    edit: Sorry, I've just re-read the full thread and realised this would probably be subject to the same issues. I don't know what to suggest

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