How do I lock the mouse to the game area only?

Get help using Construct 2

Post » Fri May 08, 2015 5:54 pm

The mouse is leaving the game area, even when exported to desktop, or preview. I must be able to lock the mouse to the game area, so that it does not leave the game area. I'm sure this is much simpler then I'm making it.

Thank you!
B
8
S
1
Posts: 28
Reputation: 906

Post » Fri May 08, 2015 6:15 pm

Wow! Now I would like to know that too o/
B
17
S
7
Posts: 280
Reputation: 2,522

Post » Fri May 08, 2015 8:43 pm

https://www.ravenheart.ca/home
I don't check the forums much anymore, but I will receive an email for PMs.

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
22
S
6
G
1
Posts: 1,418
Reputation: 4,830

Post » Fri May 08, 2015 10:41 pm

Having a similar question, i hope no one minds if i pop up another question here rather than open a new thread. Can the mouse be locked inside a certain area in the game? i'd like my top down shooter to have a restrained angle of motion with the mouse cursor that acts as the crosshair. So basically i'd need a way to halt the mouse to say in a 45 degree radius from the weapon muzzle so that the player cant aim straight behind him without first turning to face that way.
B
7
S
1
Posts: 93
Reputation: 632

Post » Fri May 08, 2015 10:47 pm

Hoping this plugin can help

plugin-mouse-lock-v0-5-updated_t102112

Looks like you'd have to recreate the cursor.
Nothing goes unanswered!
B
24
S
5
G
1
Posts: 434
Reputation: 3,446

Post » Fri May 08, 2015 10:50 pm

I noticed that plugin too, but not having used plugins before im quite at a loss as to how to use it. I got it installed allready but i dont know how to play with it?
B
7
S
1
Posts: 93
Reputation: 632

Post » Fri May 08, 2015 11:01 pm

This is a way of doing it but it is just a quick demo. You can make it much smoother if you fine tune it a bit :) This way is super simple and without plugins. Took me about 2min.

Live Demo
https://dl.dropboxusercontent.com/u/100 ... index.html

Download CapX
https://dl.dropboxusercontent.com/u/100 ... ursor.capx
B
55
S
24
G
13
Posts: 766
Reputation: 12,573

Post » Sat May 09, 2015 12:59 am

@Anonnymitet, Thank you, but this is not the intended effect, the cursor still leaves the area just not the sprite, the only real fix is to make only full screen games and forget about browser/windowed games or use this plugin or create a plugin using the Pointer Lock API.

@BriggyBros, This is exactly the intended functionality, thank you! Although I was hoping it could be done without a plugin, this will have to do.

@Ashley, So you cant lock the mouse to the center while the game action takes place, whats to happen when people want to play the game without clicking on stuff out side the game content? This is quite a huge oversight for a game engine, especially one designed to work with browsers. It is a critical flaw and should be a top priority in implementing this functionality without plugins. Especially now that the Pointer Lock API is out, hitting ESC releases the mouse, so its not a security issue. Thank you for your hard work, I look forward to seeing if this can be implemented smoothly into "mouse" without plugins.

Intended functionality > Example FPS Quake game using Pointer Lock API : http://media.tojicode.com/q3bsp/

Thank you.
B
8
S
1
Posts: 28
Reputation: 906

Post » Sat May 09, 2015 1:03 am

@Wolph I see. I didn't realize that you wanted to prevent people from clicking on stuff outside the actual game window. I make all my games full screen so haven't even thought of that problem. But now I understand you want to prevent the mouse from leaving the game area.

Hope you'll find a good workaround.
B
55
S
24
G
13
Posts: 766
Reputation: 12,573

Post » Sat May 09, 2015 9:52 am

Message: Juicy can only post plain text URLS until they have 500 rep. 2 URLS modified. Why?
Anonnymitet wrote:This is a way of doing it but it is just a quick demo. You can make it much smoother if you fine tune it a bit :) This way is super simple and without plugins. Took me about 2min.

Live Demo
https://dl.dropboxusercontent.com/u/100 ... index.html

Download CapX
https://dl.dropboxusercontent.com/u/100 ... ursor.capx


That looks very tempting, but it doesn't really stop the mouse but the sprite thats connected to it. I fear that with this, the player might "lose" the mouse cursor as the sprite wont budge unless its within the designated area. Also theres a speed problem that the sprite cant follow the cursor fast enough if you draw it to the side real quick, resulting that the sprite stops before the side.
B
7
S
1
Posts: 93
Reputation: 632

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 48 guests