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

#1 2009-11-11 15:21:33

gaving
Scratcher
Registered: 2009-11-10
Posts: 7

Im new and how would i make a sprite move to where my mouse is?

title says it all

Offline

 

#2 2009-11-11 15:24:45

Mr_X
Scratcher
Registered: 2009-09-10
Posts: 1000+

Re: Im new and how would i make a sprite move to where my mouse is?

I think you just add
<when green flag clicked>
<forever>
<point towards( mouse pointer
<move( 5)steps> or something
<end>


http://img99.imageshack.us/img99/8656/exveemonc.gif The rules of the internet:
1) Every woman is a man    2) Every man is a child    3) Every child is an FBI agent                                        I have psychopathic tendencies. Be afraid

Offline

 

#3 2009-11-11 15:29:40

gaving
Scratcher
Registered: 2009-11-10
Posts: 7

Re: Im new and how would i make a sprite move to where my mouse is?

ok, and another question, is the direction its pointing towards able to be put in a variable?

Offline

 

#4 2009-11-11 15:34:34

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Im new and how would i make a sprite move to where my mouse is?

<set{ Variable }to( <direction> )>

Offline

 

#5 2009-11-11 15:39:13

gaving
Scratcher
Registered: 2009-11-10
Posts: 7

Re: Im new and how would i make a sprite move to where my mouse is?

well that was obvious xD and thanks to both of yahs

Offline

 

#6 2009-11-11 23:08:38

Jonathanpb
Scratcher
Registered: 2008-07-25
Posts: 1000+

Re: Im new and how would i make a sprite move to where my mouse is?

What's easier is using a forever block and putting [go to [mousepointer]] into it.


"Human beings... must have action; and they will make it if they cannot find it.
-Charlotte Brontë

Offline

 

#7 2009-11-11 23:27:56

Chrischb
Scratcher
Registered: 2008-07-24
Posts: 1000+

Re: Im new and how would i make a sprite move to where my mouse is?

Jonathanpb wrote:

What's easier is using a forever block and putting [go to [mousepointer]] into it.

It depends on what the purpose is. To make it glide at a fixed pace, try this:

When Green Flag Clicked
forever
   if <mouse down>
      glide ((distance to [sprite]) / (10) secs to x ([x position] of [sprite]) y ([y position] of [sprite]).

Remember that the results are in one line; I just ran out of space.

Anyway, the sprite is to be always following the mouse pointer. Do what Jonathanpb said:

When Green Flag Clicked
forever
   go to [mouse pointer]

For the sprite that is to move, give it that first script.

Hope that helped!


I fall: It's a tragedy. You fall: It's comedy.
Hmph enjoy your fall - I get a lovely spring... without pans of new leaves.

Offline

 

#8 2009-11-11 23:46:48

Jonathanpb
Scratcher
Registered: 2008-07-25
Posts: 1000+

Re: Im new and how would i make a sprite move to where my mouse is?

Ooh... good idea to put both ways.

That looks quite complicated since it's not in blocks... but it not actually complicated.  tongue

Last edited by Jonathanpb (2009-11-11 23:47:03)


"Human beings... must have action; and they will make it if they cannot find it.
-Charlotte Brontë

Offline

 

#9 2009-11-12 12:10:17

nikkiperson2
Scratcher
Registered: 2007-12-08
Posts: 1000+

Re: Im new and how would i make a sprite move to where my mouse is?

on the sprite you want to move, make the script-
[When green flag pressed]
[forever:
[point towards [mouse]
[Take [5] steps]]

and it should slowly start moving toward the mouse once you press the green flag.


http://i.imgur.com/h9L7Ktb.pnghttp://i.imgur.com/Hz1Cg2s.png

Offline

 

#10 2009-11-12 12:37:40

jacool
Scratcher
Registered: 2008-01-25
Posts: 1000+

Re: Im new and how would i make a sprite move to where my mouse is?

nikkiperson2 wrote:

on the sprite you want to move, make the script-
[When green flag pressed]
[forever:
[point towards [mouse]
[Take [5] steps]]

and it should slowly start moving toward the mouse once you press the green flag.

Like Mr_X said  tongue


http://i571.photobucket.com/albums/ss159/JacobKar/svensktiger-1.png

Offline

 

Board footer