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

Get help using Construct 2

Post » Wed Aug 31, 2016 2:07 am

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.
Moderator
B
94
S
33
G
33
Posts: 3,006
Reputation: 27,744

Post » Wed Aug 31, 2016 5:51 am

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.
Mistakes were made.
B
49
S
24
G
107
Posts: 1,581
Reputation: 60,303

Post » Wed Aug 31, 2016 8:00 am

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.
Moderator
B
94
S
33
G
33
Posts: 3,006
Reputation: 27,744

Post » Wed Aug 31, 2016 8:37 am

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 :(
The LEVEL GENERATOR TOOLKIT



24 functions dedicated to producing randomly generated terrain for all kinds of games.
B
25
S
7
Posts: 237
Reputation: 2,296


Return to How do I....?

Who is online

Users browsing this forum: bluesun66, plinkie and 3 guests