Drag & Drop Behavior

Get help using Construct 2

Post » Wed Oct 17, 2012 2:02 pm

Hello Everyone,

I need some guidance on the drag and drop behavior for an object. I can add the behavior to an object and drag it around with touch or the mouse but the problem is when the touch or mouse stops MOVING the objects drops and the mouse button or touch is still activated . I would like to drop the object when the BUTTON or TOUCH is released

How would I go about doing that as the drag and drop behavior has no configurable options? Do I need to setup an event to handle this action?
B
4
G
1
Posts: 10
Reputation: 1,021

Post » Thu Oct 18, 2012 2:23 pm

Hey Vetie,
Drag and Drop does have one function you can call...and that is "Set Enabled" or "Disabled"
I have to say I havent encountered any problems with this at all yet
But I do make certain that for each object or Family of objects you have I usually do this

On start of Layout---> object or family="Set Drag + Drop Enabled" Enabled

You Problem sounds Peculiar....The Drag and drop function works fine usually..

Can you drop a CapX file here to sort it out....
When in doubt..or you are lost in a Zombie apocalypse or someone is giving you a hard time..Remember one thing..... Read the Construct 2 Manual..it will save your life.:)
B
29
S
11
G
8
Posts: 312
Reputation: 7,333

Post » Thu Oct 18, 2012 4:56 pm

Thanks for the response. I have been messing around with my test and have figured out what the problem is but dont quite know how to fix it.

I have an object (Block) and I was attaching the physics behavior and the Drag and Drop behavior. When I used my mouse and left clicked on the box, I could move it around the screen but when my mouse stopped moving (but still holding down the left mouse button) the block will drop to the ground.

If I remove the physics behavior, drag and drop works as intended. What I am trying to do is create a connect 4 style game where I drag the piece to the correct slot and have it fall to its lowest location and thought physics would work for this.

So basically I need the drag and drop behavior when I am moving the object but when I stop clicking (not moving) the mouse, physics will take over and drop the object due to gravity.

Is it possible to setup an event to enable or disable physics on an object based on a mouse button condition or touch condition? i.e When left button released, enable physics.

Thanks
B
4
G
1
Posts: 10
Reputation: 1,021

Post » Thu Oct 18, 2012 6:09 pm

You could make the object immoveable at "on drag start" and make it moveable again "on drop".
B
79
S
24
G
53
Posts: 4,728
Reputation: 40,219

Post » Thu Oct 18, 2012 7:27 pm

Thanks for the reply,

That was the jolt I needed!

My actor has 2 behaviors, Drag and Drop and Physics. I then created 2 events. When left mouse button down - set world gravity to 0 and When left mouse button released - set world gravity to 10.

Works exactly like I wanted.
Thanks
B
4
G
1
Posts: 10
Reputation: 1,021


Return to How do I....?

Who is online

Users browsing this forum: michaelverdi and 26 guests