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

0 favourites
  • 11 posts
From the Asset Store
Total customisation of the input! You can combine inputs from all peripherals. Make your game accessible for everyone!
  • 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!

  • Wow! Now I would like to know that too o/

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

  • Hoping this plugin can help

    Looks like you'd have to recreate the cursor.

  • 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?

  • 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 <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile"> 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

  • 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.

  • 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.

  • 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 <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" /> 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.

  • any other ideas regarding this or is this a dead end? Also is there some documentation regarding the plugin so i could see what it can do?

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