Throwing with Drag n Drop

Get help using Construct 2

Post » Sat Feb 02, 2013 9:27 pm

I would like to be able to drag something across the screen using drag-n-drop and when I let go, I would like it to continue going in the same direction at the same velocity. Any example on how this would be done?

Thank you.

mypupdaisy
-- noob and free'b owner until I can make some progress
B
3
Posts: 3
Reputation: 281

Post » Sat Feb 02, 2013 10:20 pm

You can do it very easily by using a couple of built-in functions. You'll want to determine its current speed and angle the moment it's dropped. Create an object with the drag and drop and physics behaviours.

Every tick, you'll record the object's X and Y - this becomes the previous X and Y.

To determine speed, use the formula of speed = distance / time. Distance is that between the old X/Y and current X/Y. Time is delta time. Distance(previousX, previousY, currentX, currentY)/1*dt.

To determine the angle you use a similar principle, but using the built-in angle function: Angle(previousX, previousY, currentX, currentY).

Apply the results to a physics impulse at that speed and angle and you've got yourself a solution.

Example capx [R117]: here.

Welcome to the forums!GeometriX2014-02-15 20:32:43
B
56
S
15
G
10
Posts: 910
Reputation: 11,972

Post » Sat Feb 02, 2013 11:22 pm

Thank you for the great reply. I will give this a try. Sorry, I can't try the demo you provided. I have the latest version installed and it states that I have R114 and can't load the project files.
B
3
Posts: 3
Reputation: 281

Post » Sun Feb 03, 2013 12:39 am

YES! It works great! Thank you GeometriX.
B
3
Posts: 3
Reputation: 281


Return to How do I....?

Who is online

Users browsing this forum: DemantDigitalArt, mjj1990 and 7 guests