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

#1 2007-12-06 09:35:54

football10
Scratcher
Registered: 2007-12-04
Posts: 3

MOUSE POINTER

I NEED MY CAR TO FOLLOW THE MOUSE POINTER

Offline

 

#2 2007-12-06 11:10:27

MyRedNeptune
Community Moderator
Registered: 2007-05-07
Posts: 1000+

Re: MOUSE POINTER

<when green flag clicked>
<forever>
<point towards( mouse-pointer
<move( --- )steps>
<end>


http://i52.tinypic.com/5es7t0.png I know what you're thinking! "Neptune! Get rid of those filthy advertisements and give us back the Zarathustra siggy, you horrible person!" Well, don't worry about it, the Zara siggy will be back soon, new and improved! ^^ Meanwhile, just do what the sig tells you to. >.>

Offline

 

#3 2007-12-06 12:40:21

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

Re: MOUSE POINTER

MyRedNeptune provided a script that has the car moving at a constant speed toward the mouse pointer, which is probably what football10 wanted.  It should include a wait 0.02 seconds in the loop so that it will behave the same on very fast machines as on somewhat slower machines.  A lot of people forget to have a wait in each forever loop, then wonder why their program behaves differently on a friend's machine.

There is a simpler script for following the mouse pointer that just jumps to the mouse pointer, tracking it more precisely, but not keeping a constant speed


when green flag clicked
forever
    go to mouse-pointer
    wait 0.02 seconds

Offline

 

#4 2007-12-07 21:03:15

funkymonkey
Scratcher
Registered: 2007-06-03
Posts: 1000+

Re: MOUSE POINTER

or you could do:
<when green flag clicked>
<forever>
<go to[ mouse pointer

that makes your sprite just follow the mouse

Last edited by funkymonkey (2007-12-07 21:03:52)


http://i243.photobucket.com/albums/ff67/hprules_photos/banner2.jpg
Kuzimu: Dawn of a New Age                                                                                                  Coming May 2010

Offline

 

#5 2007-12-07 22:47:25

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

Re: MOUSE POINTER

funkymonkey, your script works, but can result in competition for computer resources with other scripts, since it is trying to update the position all the time.  Adding a small wait (up to about 0.1 seconds) does not change the appearance for the user, but allows other scripts more time to do their jobs.

Offline

 

Board footer