How do I keep the mouse pointer within the fence?

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!
  • Hello everyone,

    Can you help me with the following problem.

    I am following the Breakout tutorial and just finished part 2. I am testing this game to see if it is exactly the same as the author his game.

    I fixed all mistakes I made. However I have a very nasty problem. When the mouse pointer goes outside the browsers window, the paddle does not respond any longer.

    So what I want to accomplish is that the mouse pointer remains on the same location the paddle is. So the mouse pointer exactly follow the paddle when the mouse is moved.

    Can you tell me how to solve this problem? I cannot find an answer for my problem.

    I thank you very much for your time spend on helping me out here. It is very much appreciated.

    Scirra Construct 2 is a very nice game development tool which I already like to use very much.

    Friendly greetings,

    Bad-Wolf

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • This capx should help

    https://dl.dropboxusercontent.com/u/485 ... clamp.capx

    instead of using mouse.x and/or mouse.y in your events just use object.x and/or object.y

  • I was looking for your capx. You're too fast for me LittleStain ^^

  • Hello LittleStain,

    Thank you very much for your reply and your example project. I appreciate your help very much.

    Because of your example I can explain my problem better. Your example works fine and does indeed what I expect it to do, as long as you keep your mousepointer in the white and black erea.

    However when your mousepointer comes over the taskbar or over the toolbar on top, movement of the orange square stops. That is exactly what I do not want it to do. At least the orange square should move left or right following the horizontal movement of the mousepointer.

    Imagine having a runtime (.exe) where the orange square's movement is restricted to horizontal only (left/right) even when you move your mousepointer up or down, the square should always be on the same line horizontally.

    The fence should act like a window, where the mousepointer cannnot get out.

    I am coming from a programming background and maybe I am thinking wrongly or in the wrong direction. I have the impression that my kind of thinking is flawed. If that is so, please feel free to tell me.

    Thank you again for your help, your example was very helpfull.

    Friendly greetings,

    Bad_Wolf

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