How do I pin a sprite to the mouse cursor with no delay

Get help using Construct 2

Post » Sun Oct 09, 2016 9:25 pm

I need to actually pin a sprite to the mouse cursor and not just change what the cursor looks like for code specific reasons.

Using either the Every Tick or Pin function causes the sprite to drag the faster the cursor goes.

I need this because I want a sprite to change directions when clicking depending on what side of the sprite the cursor is on, and there's no way to determine that using the mouse object that I can see.

Thanks for any help
B
8
S
3
Posts: 49
Reputation: 698

Post » Sun Oct 09, 2016 9:55 pm

Since it uses browser, there will always be lag/delay to the mouse movement. This can't be solved unfortunately.
But you could check the previous mouse position with the current position by storing the previous x,y in variables, then comparing them to the new values to find which direction the cursor has moved.
B
43
S
19
G
65
Posts: 1,105
Reputation: 37,949

Post » Sun Oct 09, 2016 10:01 pm

Hey thanks for the info.

I'm not sure what you mean about comparing the values though.

Is that a way to tell which side of my Player Sprite the cursor is on?
B
8
S
3
Posts: 49
Reputation: 698

Post » Mon Oct 10, 2016 7:50 pm

Oh, I misread it.
You can compare the sprite x position with the mouse x position, to check if one is greater or less than the other. Then mirror/unmirror the sprite based on that condition.
B
43
S
19
G
65
Posts: 1,105
Reputation: 37,949


Return to How do I....?

Who is online

Users browsing this forum: David181, manujorgo, NECRONOMICRON and 29 guests