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

#1 2012-01-02 01:16:31

MoonshineKitty
Scratcher
Registered: 2011-12-17
Posts: 16

Follow the Mouse

Hi all, I have a question:

I am trying to make a game where the sprite follows wherever you move your cursor, is this possible? Thanks!

Offline

 

#2 2012-01-02 01:55:16

Flait7
Scratcher
Registered: 2008-04-14
Posts: 100+

Re: Follow the Mouse

Yes it is possible!

<point towards( mouse-cursor )>
<move( x )steps>


http://scratch.mit.edu/static/projects/Flait7/2248016_sm.pnghttp://scratch.mit.edu/static/projects/Flait7/1827934_sm.png

Offline

 

#3 2012-01-02 03:32:11

fg123
Scratcher
Registered: 2008-11-13
Posts: 1000+

Re: Follow the Mouse

As Flait pointed out, it is possible, but as a precaution to avoid jumping around and flashing, add:

[forever if <not<(distance to [mouse pointer]) less than 5> >]
[][point towards [mouse pointer]]
[][move (x) steps]
[end forever]

Here's an image to help you: http://img256.imageshack.us/img256/3167 … wmouse.gif

Last edited by fg123 (2012-01-02 14:13:17)


Hai.

Offline

 

#4 2012-01-02 14:16:49

MoonshineKitty
Scratcher
Registered: 2011-12-17
Posts: 16

Re: Follow the Mouse

Thanks!

Offline

 

#5 2012-01-02 14:38:55

Purika
Scratcher
Registered: 2011-01-26
Posts: 100+

Re: Follow the Mouse

There are two ways to do it, one of them is Flait7´s way.

Flait7 wrote:

<point towards( mouse-cursor )>
<move( x )steps>

Another way to do it is:

<forever>
<go to[ mouse pointer
<end>

Last edited by Purika (2012-01-02 14:39:16)


https://lh3.googleusercontent.com/-ZlPXbnYAtro/TxRNNopA6XI/AAAAAAAAAvY/worvlbyfCYI/s589/Purika.gif
If I was three birds, I could see myself fly below us!  big_smile

Offline

 

#6 2012-01-02 14:45:59

Freakish
Scratcher
Registered: 2011-10-25
Posts: 1000+

Re: Follow the Mouse

A really good script to make a velocity-like way of following the mouse is to do:

<green flag clicked>
<forever
<point towards mouse-pointer>
<move <<distance to mouse>/10> steps>

Last edited by Freakish (2012-01-02 14:46:10)


http://i.imgur.com/y3RBV.jpg

Offline

 

#7 2012-01-02 15:27:57

MoonshineKitty
Scratcher
Registered: 2011-12-17
Posts: 16

Re: Follow the Mouse

Thank you! I'm testing different ways to do things so it helped a lot!

Offline

 

Board footer