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)
Offline
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
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
Your screen should look something like this:
http://img87.imageshack.us/my.php?image=untitledzj0.jpg
Offline
Isn't there a sprite with a drag-and-drop script in the sprite library? Under "things" I think.
Offline
Wow I just looked in the library and I found the drag n drop sprite and its much simpler than mine.
Offline
Where is the drag and drop sprite in the sprite library? I can't seem to find it.
Offline
Surely in scratch 1.2 you need only "unlock" the sprite using the littl epadlock icon, to make it drag-and dropable.
Offline
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.
Offline
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
umm where is the library??
im pretty new
Offline
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.
Offline
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.
Offline
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
<think [how do ya drag]for( )secs>
Offline
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
Offline
All you need to do is press the little lock button next to your sprite name to make it draggable online.
Happy Scratch-ing!
Offline
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 0i 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
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
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
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>
Offline