Legacy GM [Solved] Dragging object relative to mouse position?

Edwin

Member
I want to make a simple object dragging system, but when I drag the object it teleporting to mouse position relatively it's position offset.

How it looks like:
Reality.gif

How I want it to look:
New Piskel.gif

Well, I tried to animate it realistic and I hope you get my point.

So, how I can add mouse position to the object position offset?
 

FrostyCat

Member
When the mouse button is first pressed, measure the coordinate difference between the mouse position and the origin of the target being clicked. Then while the mouse button remains down, snap to the mouse position plus that difference.

See this example solution, where mdx and mdy represent the said coordinate difference.
 

Edwin

Member
When the mouse button is first pressed, measure the coordinate difference between the mouse position and the origin of the target being clicked. Then while the mouse button remains down, snap to the mouse position plus that difference.

See this example solution, where mdx and mdy represent the said coordinate difference.
Oh, thanks! It turned out that it was very easy to do!
 
Top