no offset drag and drop

Show us your completed creations made in Construct 2

Post » Tue Jan 03, 2012 6:45 pm

The usual method of set x,y to mouse x,y, always moves the object to its hotspot.
This method gets the offset from the hotspot, or basically gets the relative coordinate from where you clicked, and moves it there.
Ie click a corner, drag that corner, not drag from the hotspot.

Demo here:
no offset drag and drop
Image ImageImage
B
168
S
50
G
163
Posts: 8,221
Reputation: 105,061

Post » Tue Jan 03, 2012 6:52 pm

Nice :)

Thanks, newt.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
131
S
29
G
81
Posts: 5,328
Reputation: 56,630

Post » Tue Jan 03, 2012 7:59 pm

Nice example. You can also do it by delta-x and delta-y rather than distance/angle, but I guess it works the same.

FWIW I was going to add an official drag+drop behavior at some point which also supports touch.
Scirra Founder
B
387
S
230
G
87
Posts: 24,248
Reputation: 192,228

Post » Tue Jan 03, 2012 8:31 pm

Thanks.

Cool, planning on a major upgrade soon with touch screen monitor, so definitely looking forward to that Ashley.
Image ImageImage
B
168
S
50
G
163
Posts: 8,221
Reputation: 105,061

Post » Wed Jan 04, 2012 6:35 am

[QUOTE=Ashley] FWIW I was going to add an official drag+drop behavior at some point which also supports touch.[/QUOTE]

By the way, is there an official roadmap or todo list somewhere? I can't find it. Just so we know what to expect in the not-so-distant future :)

Thanks.
B
14
S
5
G
8
Posts: 235
Reputation: 5,675

Post » Thu Jan 26, 2012 2:04 pm

Hi newt,

Could this be used for touch functions aswell?

If so, how would you achieve this...
B
5
S
1
G
1
Posts: 111
Reputation: 1,122

Post » Thu Jan 26, 2012 2:30 pm

Just add the touch object, and switch out mouse.x, mouse.y, for touch.x, touch.y, and the relative conditions.

drag and drop touch

Note you will need the mouse object for preview, haven't tested on export.
Image ImageImage
B
168
S
50
G
163
Posts: 8,221
Reputation: 105,061

Post » Thu Jan 26, 2012 3:06 pm

Cheers man! Ill test it!
B
5
S
1
G
1
Posts: 111
Reputation: 1,122

Post » Thu Jan 26, 2012 3:11 pm

It works perfect,

If I just wanted to use X positions for drag and drop how would I achieve this?

At the moment it requires 4 parameters. What value do I use?2Bdigital2012-01-26 15:11:41
B
5
S
1
G
1
Posts: 111
Reputation: 1,122

Post » Thu Jan 26, 2012 3:20 pm

Not sure what you mean, Im guessing, just delete the y's.
Image ImageImage
B
168
S
50
G
163
Posts: 8,221
Reputation: 105,061

Next

Return to Completed Creations

Who is online

Users browsing this forum: No registered users and 2 guests