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

#1 2010-11-04 13:12:44

aross
New Scratcher
Registered: 2010-10-30
Posts: 6

drag and drop?

I'm making my first Scratch project for a class, and I'm almost done except for this one problem:

I have a sprite programmed to glide up and down forever on the little screen. I want to be able to click on the sprite, drag it to a specific xy place and have it stay there, whereas if you click and drag it to anywhere else in the little screen it goes back to gliding when you un-click. I've managed the second part of that, but I can't make it stay in a specific place!

I've looked through the forums for an answer and re-watched tutorials but I couldn't find anything I thought might help. Any suggestions?

Offline

 

#2 2010-11-04 14:16:58

12three
Scratcher
Registered: 2008-06-12
Posts: 1000+

Re: drag and drop?

Can you upload what you have? I find it kind of hard to understand what you're getting at.  smile

Offline

 

#3 2010-11-04 19:14:16

aross
New Scratcher
Registered: 2010-10-30
Posts: 6

Re: drag and drop?

Right, sorry!

http://scratch.mit.edu/projects/aross/1394986

My entire project is too big to upload, so I made a separate one with just the background/sprites for the one level. The kanji pieces glide the way I want them to, and go back after you click and drag them around. Now I just need the right blocks in the right order so that when you click/drag a kanji piece to the right colored box, it stops moving!

I've tried a dozen combos on my own, adding to both "when green flag clicked" and "when sprite is clicked." It's obvious by now I have no idea what I'm doing. Again, any help is appreciated.

Offline

 

#4 2010-11-04 21:34:37

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: drag and drop?

so which one goes where?


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

#5 2010-11-05 00:05:58

aross
New Scratcher
Registered: 2010-10-30
Posts: 6

Re: drag and drop?

Well I figured if I could just get one to go in any box I could apply the code to all the pieces, but here is a picture of what it should look like in the end: http://img51.imageshack.us/i/allboxes.jpg/

(New Scratchers aren't allowed to post pictures, sorry.)

Offline

 

#6 2010-11-05 02:54:06

dazman
Scratcher
Registered: 2008-02-21
Posts: 26

Re: drag and drop?

Just make it repeat until its touching the correct box color.


http://scratch.mit.edu/static/icons/buddy/82338_med.png

Offline

 

#7 2010-11-05 07:40:10

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: drag and drop?

So in the game is it possible to put them in the wrong order and lose?


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

#8 2010-11-05 07:41:57

recycle49
Scratcher
Registered: 2009-12-21
Posts: 1000+

Re: drag and drop?

Iu dont quit understand what you need


"Every challenge must be met, every battle must be won, and every story will end." -Me
Recycle49 December 09 - November 11 Goodbye

Offline

 

#9 2010-11-05 09:07:38

aross
New Scratcher
Registered: 2010-10-30
Posts: 6

Re: drag and drop?

Well right now it's not possible to put them in any order since they won't stick. ^_^; My idea is that you pick a kanji piece, put it in the box you think is right, and when you un-click it either sticks (which means you got it right) or it goes back to gliding (which means you got it wrong). I was able to make the script for all the "wrong" answers, but I can't figure out out to make the "right" answers.

So for example, the very first kanji piece to the left, I want to be able to drag it to the top aqua box and put it there, whereas if you try and put it in any of the other boxes it won't stick.

AtomicBawm3, I thought about making the game closer to what you're saying, where you put 3 pieces in boxes and on the 4th piece you find out if you did it in the right order, however there are 24 possible combinations and I thought that would be too frustrating.

Offline

 

#10 2010-11-06 01:28:08

wei2912
Scratcher
Registered: 2010-05-09
Posts: 100+

Re: drag and drop?

For each piece:

Let's say the 2nd piece is supposed to be in the blue box. Here's how:
if mouse down? and touching[mouse]
if touching color[blue]
go to[(Box location)]
else
go to [(The location it started from)]

If you need more help, comment on my project.

Last edited by wei2912 (2010-11-06 01:33:34)


Waiting for Scratch 2.0...

Offline

 

#11 2010-11-06 01:34:47

wei2912
Scratcher
Registered: 2010-05-09
Posts: 100+

Re: drag and drop?

aross wrote:

Well right now it's not possible to put them in any order since they won't stick. ^_^; My idea is that you pick a kanji piece, put it in the box you think is right, and when you un-click it either sticks (which means you got it right) or it goes back to gliding (which means you got it wrong). I was able to make the script for all the "wrong" answers, but I can't figure out out to make the "right" answers.

So for example, the very first kanji piece to the left, I want to be able to drag it to the top aqua box and put it there, whereas if you try and put it in any of the other boxes it won't stick.

AtomicBawm3, I thought about making the game closer to what you're saying, where you put 3 pieces in boxes and on the 4th piece you find out if you did it in the right order, however there are 24 possible combinations and I thought that would be too frustrating.

Actually, there is another way.

Just put if it is not in the correct order, you will lose the game.

After all, there's only 1 correct order.  smile


Waiting for Scratch 2.0...

Offline

 

#12 2010-11-09 14:13:22

aross
New Scratcher
Registered: 2010-10-30
Posts: 6

Re: drag and drop?

I've almost got it!

An updated version is here: http://scratch.mit.edu/projects/aross/1404905

The code works for the most part, except that the first few times you try and put a piece in a box it won't work! Maybe the 2nd or 3rd try it works just fine, but I can't figure out why it doesn't just work the first time.

You do have to put the pieces directly in the center of the box, but it still takes more than one try even if you place it perfectly. WHYYYYYY!

Offline

 

#13 2010-11-09 16:32:48

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: drag and drop?

aross wrote:

I've almost got it!

An updated version is here: http://scratch.mit.edu/projects/aross/1404905

The code works for the most part, except that the first few times you try and put a piece in a box it won't work! Maybe the 2nd or 3rd try it works just fine, but I can't figure out why it doesn't just work the first time.

You do have to put the pieces directly in the center of the box, but it still takes more than one try even if you place it perfectly. WHYYYYYY!

Did you set the x and y position to have to be one specific coordinate? If so, it's probably just that you're not placing it at the one space it needs to be. Try expanding the allowed positions to a small range.


http://www.blocks.scratchr.org/API.php?action=random&return=image&link1=http://i.imgur.com/OZn2RD3.png&link2=http://i.imgur.com/duzaGTB.png&link3=http://i.imgur.com/CrDGvvZ.png&link4=http://i.imgur.com/POEpQyZ.png&link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#14 2010-11-09 18:29:50

aross
New Scratcher
Registered: 2010-10-30
Posts: 6

Re: drag and drop?

Harakou wrote:

Did you set the x and y position to have to be one specific coordinate? If so, it's probably just that you're not placing it at the one space it needs to be. Try expanding the allowed positions to a small range.

It didn't work for me.  sad  I tried to make it so that you could put the kanji a little outside the lines and it would still work, but once I put in the code ' if x is less than this but greater than this, and same for y, go to xy position and stop' the pieces stopped sticking in the box entirely.

Offline

 

#15 2010-11-09 18:39:15

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: drag and drop?

aross wrote:

Harakou wrote:

Did you set the x and y position to have to be one specific coordinate? If so, it's probably just that you're not placing it at the one space it needs to be. Try expanding the allowed positions to a small range.

It didn't work for me.  sad  I tried to make it so that you could put the kanji a little outside the lines and it would still work, but once I put in the code ' if x is less than this but greater than this, and same for y, go to xy position and stop' the pieces stopped sticking in the box entirely.

Make sure that the minumum x value is less than the maximum. (Same with y) also, x has to be greater than the minimum value, not less than. That's a mistake people sometimes make.  tongue


http://www.blocks.scratchr.org/API.php?action=random&return=image&link1=http://i.imgur.com/OZn2RD3.png&link2=http://i.imgur.com/duzaGTB.png&link3=http://i.imgur.com/CrDGvvZ.png&link4=http://i.imgur.com/POEpQyZ.png&link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#16 2010-11-10 09:22:03

wei2912
Scratcher
Registered: 2010-05-09
Posts: 100+

Re: drag and drop?

I wish i can help you, but i can't till tommorow·


Waiting for Scratch 2.0...

Offline

 

#17 2010-11-16 09:34:09

wei2912
Scratcher
Registered: 2010-05-09
Posts: 100+

Re: drag and drop?

a bump


Waiting for Scratch 2.0...

Offline

 

Board footer