Multiple drand and drop

Get help using Construct 2

Post » Tue Sep 10, 2013 8:06 pm

The drag and drop is a neat behaviour, I love how easy it is to use.

I am trying to make a map editor, and right now I need to find out how I can drag and drop multiple sprites.

The obvious was for me to add drag and drop to the sprite and backgrounds I wanted to move, but the only sprites effected are the ones directly under the mouse.

I have all the objects with a "Selected off =0, or 1 for on", I want to move only the ones with selected = 1.

Is there some way to tell all the selected sprites to track the mouses X and track the mouses Y movements?

Thanks in advanced.
B
29
S
8
G
4
Posts: 767
Reputation: 5,985

Post » Tue Sep 10, 2013 10:47 pm

https://www.dropbox.com/s/vge54fyvya5v8r4/cap.JPG

Thats how I do it. drag and drop wasn't really doing it for me. if you spawned an item after a click you had to re-click to drag, this way grabs it and holds it until you let goJWstudios2013-09-10 22:59:43
B
10
S
2
G
1
Posts: 77
Reputation: 1,278

Post » Tue Sep 10, 2013 10:50 pm

.JWstudios2013-09-10 23:01:20
B
10
S
2
G
1
Posts: 77
Reputation: 1,278

Post » Tue Sep 10, 2013 10:53 pm

I would do it along these lines i think:

on left click on sprite :
    if selected
        Sprite selected = False
    else
        Sprite selected = True
        Sprite xOffset = self.X - Mouse.X
        Sprite yOffset = self.Y - Mouse.Y

When dragging:

for each sprite
    if selected :
        set X to Mouse.X+self.xOffset
        set Y to Mouse.Y+self.yOffset
B
20
S
6
G
4
Posts: 347
Reputation: 4,451

Post » Tue Sep 10, 2013 11:12 pm

Or you could pin the selected sprites to the one you're dragging: dragDropMultiple.capx
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,650

Post » Wed Sep 11, 2013 2:12 am

@JWstudios, @cvp, @ramones,

Thank you all so much!

I came looking for a solution, and come to find 3 excellent solution's!!

You guys rock, thanks!
B
29
S
8
G
4
Posts: 767
Reputation: 5,985


Return to How do I....?

Who is online

Users browsing this forum: beohs, Blendi1223, Elliott, MadSpy and 11 guests