Discuss Scratch

cubby208
Scratcher
99 posts

A pulling question!

I have a game and I want every object to go twords the mouse. The important thing is that the farther it is the slower and the closer it is the faster. This pull will only happn when the mouse is down. Any ideas on how I can get this to happen? Scratchblocks much appreciated!
Glboom
Scratcher
4 posts

A pulling question!

You could broadcast it:
foreverifmousedownthenbroadcastLook

And in the object that you want to look at the mouse and move:
whenIreceiveLookpointtowardsmouse-pointermove100/distancetomouse-pointersteps
So what happens is the closer you are to the mouse pointer,
the less 100 steps gets divided, meaning faster movement.



This code makes the object move slower the closer it is:
whenIreceiveLookpointtowardsmouse-pointermovedistancetomouse-pointer/10steps
scubajerry
Scratcher
1000+ posts

A pulling question!

cubby208
Scratcher
99 posts

A pulling question!

scubajerry wrote:

How about this?

http://scratch.mit.edu/projects/12389162/
Wow your a miracle worker! You allways aw set my questions your a great community member!
HeroBrineNZK
Scratcher
82 posts

A pulling question!

Sometimes this works
whenclickedforevergotomouse pointer
because the further the mouse is, it takes longer for the computer to get a sprite to go to the pointer
jasonsrvca
Scratcher
1 post

A pulling question!

Glboom wrote:

You could broadcast it:
foreverifmousedownthenbroadcastLook

And in the object that you want to look at the mouse and move:
whenIreceiveLookpointtowardsmouse-pointermove100/distancetomouse-pointersteps
So what happens is the closer you are to the mouse pointer,
the less 100 steps gets divided, meaning faster movement.



This code makes the object move slower the closer it is:
whenIreceiveLookpointtowardsmouse-pointermovedistancetomouse-pointer/10steps


Thank you, this helped so much!

Last edited by jasonsrvca (March 27, 2014 02:14:55)

Powered by DjangoBB