Click and Drag Mechanic

Get help using Construct 2

Post » Fri Sep 09, 2011 10:40 pm

Hi guys,

New to Construct 2 and the forums. I'm using to prototype some things right now. I searched and didn't find anything so I figured I'd ask.

Is there a way I can add a click and drag mechanic to my game?
For example, I want to be able to take a sprite and drag it into a another sprite, and have them lock together at a specific position.

Any help is appreciated.
B
2
S
1
G
1
Posts: 4
Reputation: 708

Post » Fri Sep 09, 2011 11:14 pm

I would say... have an event: if cursor is over object AND mouse button is down. Then the action would be set position at mouse.x and mouse.y.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Fri Sep 09, 2011 11:17 pm

This mechanic is used and described in the example capx for the pathfinder behavior.

Edit: also it starts as squiddster descirbed just above.Kyatric2011-09-09 23:19:31
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,805

Post » Sun Sep 11, 2011 3:58 pm

Thank you sqiddster and Kyatric!
That's pretty much what I wanted. Except when I created two separate events for two separate objects, they ended up locking together.
B
2
S
1
G
1
Posts: 4
Reputation: 708

Post » Sun Sep 11, 2011 4:24 pm

Can you post a capx, or describe a bit more how you set up your project, what happens and what you expected to happen ?

You can check in the PathFinder behavior the way it is done is by making sure that the drag/drop will "happen" if no other drag/drop is "happening" already.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,805

Post » Sun Sep 11, 2011 4:33 pm

The capx isn't complicated at all
The issue actually happens with your demo as well (http://dl.dropbox.com/u/36472942/construct/plugin/release/pathfinder/demo/index.html)
If you click and drag either the S or D around, it works fine. But if you're dragging the S and it moves over the D, they will both lock together because the project will register your mouse being over both the original sprite and the one you're moving over.
B
2
S
1
G
1
Posts: 4
Reputation: 708

Post » Sun Sep 11, 2011 5:57 pm

Oh that was a bug. Nice catch.
Redownload the capx, I edited it.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,805

Post » Tue Sep 27, 2011 3:59 am

I probably already know the answer to this but...I downloaded the capx and tried opening it and got all sorts of error codes regarding Behavior type uses unknown ID in event file such and such.

I am assuming this may be because there are 100+ events and I am using the free version r58.

Is anyone with the full version running into the same issue though? Or do I have to install the path finder behavior in order to run this capx?
B
22
S
9
G
3
Posts: 203
Reputation: 3,647

Post » Tue Sep 27, 2011 4:08 am

May try this behavior plugin:drag & drop

The drag&drop will pick the topmost(max zindex) instance if overlapping.
B
97
S
22
G
179
Posts: 4,125
Reputation: 104,557

Post » Tue Sep 27, 2011 4:14 am

You have to install the PathFinder Behavior.
Also I must admit I did not thought about free edition, the capx contains 5 layers.
I don't know if this will prevent loading or not.

Let me know.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,805

Next

Return to How do I....?

Who is online

Users browsing this forum: Colludium and 26 guests