This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2007-07-18 18:33:19

Dirge
Scratcher
Registered: 2007-06-27
Posts: 15

Drag N Drop again

Ummm Im doing like a drag and drop dress up game thing, but the drag and drop thing is like...well when you try to drag something then ALL of the clothes and stuff go to your mouse cursor! what did I do wrong?

I scripted it like this:

when flag clicked:
set dragndrop to: 0
forever if dragndrop=1
go to mouse pointer

when sprite clicked
if dragndrop= 0
set dragndrop to 1
else
set dragndrop to 0

did I do it right?

CHEERS

******14**YR**OLD******Dirgy




-------------------------------------------------------------
Door: whats your name?
Richard: Richard. Richard Meyhew. Dick.
Door: Well hello richardrichardmeyhewdick!
---------------------------------------------------------------

Offline

 

#2 2007-07-19 13:53:49

Greatdane
Scratcher
Registered: 2007-06-05
Posts: 1000+

Re: Drag N Drop again

Not right. A much simpler script is:
When green flag clicked
forever if touching mouse pointer and mouse down?
repeat until not touching mouse pointer
go to mouse pointer

Another way is:
When green flag clicked
forever if touching mouse pointer and mouse down?
set dragging to 1
repeat until not touching mouse pointer
go to mouse pointer
set dragging to 0

Hope it helps


The future belongs to those who believe in the beauty of their dreams.
        ~ Eleanor Roosevelt

Offline

 

#3 2007-07-19 13:56:33

Greatdane
Scratcher
Registered: 2007-06-05
Posts: 1000+

Re: Drag N Drop again

Oops, this may take a lot of explaining but it's better if:                                             

When green flag clicked
forever if touching mouse pointer and mouse down?
set dragging to 1
repeat until not mouse down
go to mouse pointer
set dragging to 0


The future belongs to those who believe in the beauty of their dreams.
        ~ Eleanor Roosevelt

Offline

 

#4 2007-07-19 15:14:57

Dave911
Scratcher
Registered: 2007-06-27
Posts: 36

Re: Drag N Drop again

Nah you dont even need a variable but Greatdane's first script won't work. You'll need:

When F Clicked,
Forever if <<touching mouse pointer> AND <mouse down>>
Repeat until <not <mouse down>>
Go to mouse pointer.

That is the basic drag and drop script, when it is clicked and the mouse button is held is will follow the mouse and only that.

The problem with your script was that it had a single variable controlling all the clothes, they ALL reacted when you clicked on one because they were all responding to the same variable.

Offline

 

#5 2007-07-20 05:59:33

Mick
Scratcher
Registered: 2007-03-23
Posts: 100+

Re: Drag N Drop again

Ye maybe u should make each clothing item its own variable.


Go to www.legoless.com
It's my blog.  big_smile

Offline

 

#6 2007-07-20 06:08:54

bigB
Scratcher
Registered: 2007-06-09
Posts: 100+

Re: Drag N Drop again

when sprite clicked
repeat until not mouse down
go to mouse pointer.


http://scratch.mit.edu/projects/bigB/260981 Draw to Text
http://scratch.mit.edu/projects/bigB/181829 3D Stunt Flyer

Offline

 

#7 2007-07-23 06:14:21

Greatdane
Scratcher
Registered: 2007-06-05
Posts: 1000+

Re: Drag N Drop again

OK, here it goes:
forever if mouse down? and touching mouse pointer
if dragging =0
set dragging to 1


The future belongs to those who believe in the beauty of their dreams.
        ~ Eleanor Roosevelt

Offline

 

#8 2007-07-23 06:15:31

Greatdane
Scratcher
Registered: 2007-06-05
Posts: 1000+

Re: Drag N Drop again

repeat until not mouse down?
go to mouse pointer


The future belongs to those who believe in the beauty of their dreams.
        ~ Eleanor Roosevelt

Offline

 

#9 2007-07-23 06:16:03

bigB
Scratcher
Registered: 2007-06-09
Posts: 100+

Re: Drag N Drop again

you dont need variables!

when sprite clicked
repeat until not mouse down
go to mouse pointer.


http://scratch.mit.edu/projects/bigB/260981 Draw to Text
http://scratch.mit.edu/projects/bigB/181829 3D Stunt Flyer

Offline

 

#10 2007-07-23 06:20:12

Greatdane
Scratcher
Registered: 2007-06-05
Posts: 1000+

Re: Drag N Drop again

no! look! if you drag a sprite over a sprite, they both go together!


The future belongs to those who believe in the beauty of their dreams.
        ~ Eleanor Roosevelt

Offline

 

#11 2007-07-23 08:00:13

Mayhem
Scratcher
Registered: 2007-05-26
Posts: 1000+

Re: Drag N Drop again

To avoid picking up multiple things, I think you will need a variable.

WHEN Sprite1 clicked
IF (Dragging)=0
--Set (Dragging) to 1
--Repeat Until NOT Mousedown
----Goto Mousepointer
--Set Dragging to zero

-- indicates command is inside the "IF" block
---- indicates the command is inside the "Repeat" block.


Web-spinning Spider:  http://scratch.mit.edu/projects/Mayhem/18456
3D Dungeon Adventure:  http://scratch.mit.edu/projects/Mayhem/23570
Starfighter X: http://scratch.mit.edu/projects/Mayhem/21825
Wandering Knight: http://scratch.mit.edu/projects/Mayhem/28484

Offline

 

#12 2007-07-23 08:28:27

Greatdane
Scratcher
Registered: 2007-06-05
Posts: 1000+

Re: Drag N Drop again

That was my idea!


The future belongs to those who believe in the beauty of their dreams.
        ~ Eleanor Roosevelt

Offline

 

#13 2007-07-23 09:09:40

bigB
Scratcher
Registered: 2007-06-09
Posts: 100+

Re: Drag N Drop again

when sprite clicked
repeat until mouse down
goto mousepointer

this does not pickup more than one but you have to click and hold the mouse and drag away from the sprite to release.


http://scratch.mit.edu/projects/bigB/260981 Draw to Text
http://scratch.mit.edu/projects/bigB/181829 3D Stunt Flyer

Offline

 

Board footer