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

#1 2013-04-27 22:13:44

zato-1
New Scratcher
Registered: 2013-04-27
Posts: 1

Saving TWO co-ordinates using <mousedown?> block into variables?

I can save one set of co-ordinates (say variables: "x1","y1") values on a single mouse click, but cannot seem to get it to save another click into (say variables: "x2","y2"). ie. its always the same...

Thank you,

Offline

 

#2 2013-04-27 22:31:44

CAA14
Scratcher
Registered: 2013-01-14
Posts: 1000+

Re: Saving TWO co-ordinates using <mousedown?> block into variables?

You will either need another variable, or you could try this:

when clicked
forever
wait until
mouse down?
set
x1
to
mouse x
set
y1
to
mouse y
wait until
mouse down?
set
x2
to
mouse x
set
y2
to
mouse y

You will probably have to change the loop, but you get the idea. Tell me if this works, and if not, then i can think up another way.  smile

Regards,

CAA14

Last edited by CAA14 (2013-04-27 22:32:07)

Offline

 

#3 2013-04-28 11:34:02

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: Saving TWO co-ordinates using <mousedown?> block into variables?

Just to show you, the script below is a variation of CAA14's method which let's you store the previous mouse click and the current one while staying a bit more up-to-date. You might find it helpful. ;)

when clicked
forever
wait until
mouse down?
set
x2
to
x1
Previous click.
set
y2
to
y1
Previous click.
set
x1
to
mouse x
Current click.
set
y1
to
mouse y
Current click.

With regards,

ErnieParke

Last edited by ErnieParke (2013-04-28 11:34:24)


http://i46.tinypic.com/35ismmc.png

Offline

 

Board footer