How do I keep the mouse pointer within the fence?

Get help using Construct 2

Post » Sun Jul 19, 2015 9:35 pm

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
B
21
S
6
Posts: 126
Reputation: 1,771

Post » Sun Jul 19, 2015 10:40 pm

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 told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sun Jul 19, 2015 10:50 pm

I was looking for your capx. You're too fast for me @LittleStain ^^
Image Image
B
23
S
13
G
135
Posts: 871
Reputation: 70,345

Post » Mon Jul 20, 2015 10:22 am

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
B
21
S
6
Posts: 126
Reputation: 1,771


Return to How do I....?

Who is online

Users browsing this forum: David181, evillair, Fenix18, Yahoo [Bot] and 45 guests