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

#1 2007-06-27 17:50:43

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

DRAG AND DROP

How do you program a little sprite thing or whatever so that you can just drag and drop it during the game?


Much appriciated,
a 14yrold Dirge

Offline

 

#2 2007-06-27 18:17:45

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: DRAG AND DROP

This is how to drag a sprite


make a varrible called dragndrop

then put this code on a sprite

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

Last edited by archmage (2007-06-28 00:29:36)


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#3 2007-06-27 23:09:11

kevin_karplus
Scratcher
Registered: 2007-04-27
Posts: 1000+

Re: DRAG AND DROP

I had a slightly different version of the code for my stamp tool in the architecture stamps:
http://scratch.mit.edu/projects/kevin_karplus/12280

repeat until stop_stamping > 0
  go to mouse pointer
  if mouse_down and abs(mouse x)<360 and abs(mouse y<240)
      stamp
      wait until not mouse down

This allows dragging without the mouse clicked, stamping when you click.

(The code in the sprite is a little fancier, as it has to handle erasers as well, which continue erasing as long as the mouse is held down.)

Offline

 

#4 2007-06-27 23:29:47

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

Re: DRAG AND DROP

um archmage... thanks a ton! but I cant get it to work lol I know sad huh...
the problem is the first part the "forever if dragndrop = 1 follow mouse-pointer" part
its the orange forever if, and then a green numbers thing, then dragndrop in the first spot, and then what? I dunno how to get a 1 follow mouse pointer in there haha i know im sorry Im such noob but Id apreciate any advice!!

THANK YOU!!

Offline

 

#5 2007-06-28 00:28:54

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: DRAG AND DROP

Your screen should look something like this:
http://img87.imageshack.us/my.php?image=untitledzj0.jpg


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#6 2007-06-28 01:09:27

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

Re: DRAG AND DROP

Isn't there a sprite with a drag-and-drop script in the sprite library?  Under "things" I think.


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

 

#7 2007-06-28 01:38:31

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: DRAG AND DROP

Wow I just looked in the library and I found the drag n drop sprite and its much simpler than mine.


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#8 2008-03-30 17:05:59

HenryMagician
Scratcher
Registered: 2008-03-30
Posts: 1

Re: DRAG AND DROP

Where is the drag and drop sprite in the sprite library?  I can't seem to find it.

Offline

 

#9 2008-03-30 17:11:55

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

Re: DRAG AND DROP

Surely in scratch 1.2 you need only "unlock" the sprite using the littl epadlock icon, to make it drag-and dropable.


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

 

#10 2008-04-24 08:07:03

likegames
Scratcher
Registered: 2008-03-24
Posts: 100+

Re: DRAG AND DROP

click the lock to dragndrop on website


There are 10 types of people in this world: Those who understand trinary, those who don't, and those who think this is the same old signature.
Three lines! (and base three!)

Offline

 

#11 2008-04-24 14:10:53

Jacobo
Scratcher
Registered: 2007-06-15
Posts: 100+

Re: DRAG AND DROP

mayhem and likegames are right. In the area of the screen where it shows the sprites direction, there is also a olck. Click it to unlock it. When unlocked you can drag and drop the sprite without a script.


"It's like deja vu all over again"
-Yogi Berra

Offline

 

#12 2008-08-26 04:05:53

nightgal339
Scratcher
Registered: 2008-07-31
Posts: 10

Re: DRAG AND DROP

archmage wrote:

This is how to drag a sprite


make a varrible called dragndrop

then put this code on a sprite

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

i tried it it didn't work for me; if you put that on more than 1 sprite, then the other sprites go the same way that 1 does

Offline

 

#13 2008-08-26 04:21:00

nightgal339
Scratcher
Registered: 2008-07-31
Posts: 10

Re: DRAG AND DROP

umm where is the library??

im pretty new

Offline

 

#14 2008-08-26 05:35:36

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: DRAG AND DROP

nightgal339 wrote:

umm where is the library??

im pretty new

When they talk about the library, I'm pretty sure they are just talking about the projects that come with Scratch when you install it.  If you go to Open -> Projects you will see Games, Greetings, Interactive Art and so on.  That is the "library" they are refering to.

If you are looking for the Drag and Drop code...you don't need it anymore.  With the release of version 1.2, you can make any sprite Drag and Drop without any coding at all.  You just have to click on the little padlock icon up by the sprite name and make sure it is unlocked.


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#15 2008-08-26 05:41:16

06dknibbs
Scratcher
Registered: 2008-01-29
Posts: 1000+

Re: DRAG AND DROP

You no longer need to code it up at the top where you name your sprite there's a black padlock if it's unlocked you can drag and if it's locked you can't drag.

Although if you want the codes you can press choose a new sprite from a file button,click the THINGS folder and find the one called DRAGGABLE.


http://i404.photobucket.com/albums/pp129/06dknibbs/Untitled-3-6.jpg

Offline

 

#16 2008-08-26 12:55:04

mletreat
Scratcher
Registered: 2008-05-01
Posts: 100+

Re: DRAG AND DROP

nightgal339 wrote:

umm where is the library??

im pretty new

They also might be referring to the library of sprites that comes with scratch. 
This is a collection of many images you can use in your project, such as people, objects, fantasy characters, and more.

Under the stage you will see three icons.  The one in the middle with a star on it will bring you to the sprite library.

Offline

 

#17 2008-09-06 12:42:30

nightgal339
Scratcher
Registered: 2008-07-31
Posts: 10

Re: DRAG AND DROP

okay thanx guys

Offline

 

#18 2008-10-25 12:23:08

Philanatior
Scratcher
Registered: 2008-07-03
Posts: 1

Re: DRAG AND DROP

<think [how do ya drag]for(  )secs>

Offline

 

#19 2009-01-20 21:55:00

sfg
Scratcher
Registered: 2008-12-31
Posts: 11

Re: DRAG AND DROP

<when green flag clicked><forever if><<<mouse down?><<  <and>  >><touching[Mouse pointer]<go to[Mouse Pointer]

Offline

 

#20 2009-01-21 05:52:00

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: DRAG AND DROP

sfg wrote:

<when green flag clicked><forever if><<<mouse down?><<  <and>  >><touching[Mouse pointer]<go to[Mouse Pointer]

This will work...but it's easier to just unlock the sprite using the little padlock symbol up by the sprite name.  No scripting required!

http://scratch.mit.edu/projects/keroro645/288561


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#21 2009-01-21 11:11:50

pokemon_master12
Scratcher
Registered: 2008-09-26
Posts: 100+

Re: DRAG AND DROP

All you need to do is press the little lock button next to your sprite name to make it draggable online.

Happy Scratch-ing!  smile


My Dragon Egg! http://dragcave.net/image/5YUA.gif
Visit my blog: http://freyasworld.wordpress.com/

Offline

 

#22 2009-04-23 17:20:10

Jaedwin
Scratcher
Registered: 2009-04-23
Posts: 1

Re: DRAG AND DROP

nightgal339 wrote:

archmage wrote:

This is how to drag a sprite


make a varrible called dragndrop

then put this code on a sprite

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

i tried it it didn't work for me; if you put that on more than 1 sprite, then the other sprites go the same way that 1 does

Same, Can anyone fix?

Offline

 

#23 2009-04-23 19:56:43

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: DRAG AND DROP

It works just fine. All you do is click it once. Let go of mouse-button and move it around and then to stop it just click it again.

Offline

 

#24 2009-11-30 09:04:40

markotsay7
Scratcher
Registered: 2009-11-30
Posts: 1

Re: DRAG AND DROP

Sorry to bump this old thread but I need some help...I want to create something where a user can drag a sprite and once it touches another sprite "Good job!" is broadcast. However, I can't seem to get it to work right...

Right now I have unlocked all the sprites and have:

<when[ sprite1 ]clicked>
<if touching sprite2>
<say[ good job! ]for( 2 )secs>

Offline

 

#25 2009-11-30 18:27:11

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

Re: DRAG AND DROP

markotsay7 wrote:

Sorry to bump this old thread but I need some help...I want to create something where a user can drag a sprite and once it touches another sprite "Good job!" is broadcast. However, I can't seem to get it to work right...

Right now I have unlocked all the sprites and have:

<when[ sprite1 ]clicked>
<if touching sprite2>
<say[ good job! ]for( 2 )secs>

Make a new thread.

just do:
[blocks]
<forever>
<if><< <mouse down? <and> <touching[ mouse pointer ]> >>
<if><touching[ whatever sprite ]>
<say[ Good Job! ]for( 2 )secs>
<end>
<end>
<end>


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

Offline

 

Board footer