How do I separate Drag Drop and Click?

Get help using Construct 2

Post » Mon Feb 13, 2017 3:25 am

When I click a tile sprite I want it to rotate which is no problem.

When I drag a tile onto a grid I want it to pop into place by doing an onOverlap, Set Position,Play SFX(snapping sound).

The problem is clicking the sprite to rotate it triggers the DragDrop. So it repeats the DragDrop code when rotating. I've tried with various booleans, but it seems like separating the two functions is not easy.

Is anyone else using drag/drop with being able to rotate sprites?

thanks..
B
98
S
32
G
16
Posts: 1,204
Reputation: 16,715

Post » Mon Feb 13, 2017 4:22 am

Just a guess since you don't have a capx to look at.

I would separate them by using right click for rotate and left click for drag and drop.


If you are using a touchpad it could be On Object double tap for rotate

On object tap and hold for drag and drop
Banned User
B
27
S
7
G
58
Posts: 1,229
Reputation: 34,790

Post » Mon Feb 13, 2017 6:32 am

There are probably better ways to do this but here's what I'd do with my limited knowledge of C2.

The problem I encountered with Drag and Drop is that if you try and enable and disable the Drag and Drop function Mid-click it doesn't work. I think for it to be "Drag and Drop" you really have to click on the sprite on click/touch start.

So I created a Timer that sets your button to the default position when a certain "Click Time" variable hasn't been surpassed yet. This is my workaround to override the Drag and Drop function. Note this capx isn't perfect yet.

Please share your solution if you manage to fix my CAPX:
https://www.dropbox.com/s/sk5z383bph1ry ... .capx?dl=0
Image Image Image
B
31
S
11
G
27
Posts: 748
Reputation: 17,093

Post » Mon Feb 13, 2017 9:38 am

B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Mon Feb 13, 2017 10:59 am

99Instances2Go wrote:Or something like this.

https://www.dropbox.com/s/rsh0se6o0al92 ... .capx?dl=0


Even better. Mine was super complicated... :lol:
Image Image Image
B
31
S
11
G
27
Posts: 748
Reputation: 17,093

Post » Mon Feb 13, 2017 3:32 pm

99Instances2Go wrote:Or something like this.

https://www.dropbox.com/s/rsh0se6o0al92 ... .capx?dl=0



I like this approach.. so you are 'overloading' the dragdrop behavior by saying if they started the drag drop behavior and they didn't actually drag it anywhere (stays in same place) then treat that as a single click, otherwise treat it as a normal drag/drop.

awesome.. perfect, that is EXACTLY what I was looking for... thanks!

in my opinion the Drag/Drop behavior is faulty... isDragging should not turn TRUE until the X/Y has actually changed to separate it from the single left-click. Instead it turns TRUE as soon as you click it...which is wrong logically (since I only clicked it) and wrong practically since I now have to jump through hoops to get a single click trigger separated.
Last edited by jobel on Mon Feb 13, 2017 5:50 pm, edited 1 time in total.
B
98
S
32
G
16
Posts: 1,204
Reputation: 16,715

Post » Mon Feb 13, 2017 3:39 pm

thank you community for helping me to figure it out... you rock as usual!
B
98
S
32
G
16
Posts: 1,204
Reputation: 16,715


Return to How do I....?

Who is online

Users browsing this forum: kellehk and 25 guests