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

#1 2007-06-05 00:01:23

oram
Scratcher
Registered: 2007-06-01
Posts: 5

How to "Stop Motion"?

I really need help. How do u stop moving without having 2 stop the whole thing?

Offline

 

#2 2007-06-05 08:13:45

Duncan
Scratcher
Registered: 2007-05-15
Posts: 47

Re: How to "Stop Motion"?

It depends what you are doing.  If you have a sprite moving and want to stop when it touches (for example) another sprite add a Sensing test to your loop...

Repeat Until Touching Sprite 2?
  Move 10 steps
  if on edge, bounce

Or you could test to see if it is touching a certain colour. 

Or you could use a Broadcast instruction when something happens that tells an individual sprite to stop moving.

Offline

 

#3 2007-06-05 13:35:12

Mayhem
Scratcher
Registered: 2007-05-26
Posts: 1000+

Re: How to "Stop Motion"?

Sprites don't move unless you tell them to, so its not really

"Tell the sprite to stop moving"

rather

"Stop telling the sprite to move"

How to stop it will depend on how you are telling it to move, of course.  Easiest thing is probably to put an "if" statement of some sort just before the movement instruction that checks to make sure its stopping condition (touching another sprite, for example) has not been met - and if it has, don't proceed to the movement instruction.


Web-spinning Spider:  http://scratch.mit.edu/projects/Mayhem/18456
3D Dungeon Adventure:  http://scratch.mit.edu/projects/Mayhem/23570
Starfighter X: http://scratch.mit.edu/projects/Mayhem/21825
Wandering Knight: http://scratch.mit.edu/projects/Mayhem/28484

Offline

 

#4 2007-06-06 01:19:40

oram
Scratcher
Registered: 2007-06-01
Posts: 5

Re: How to "Stop Motion"?

thanks that sort of helps I guess

Offline

 

#5 2007-06-06 11:17:57

mungojelly
Scratcher
Registered: 2007-05-19
Posts: 35

Re: How to "Stop Motion"?

You can stop something that's happening over and over because of a "forever" block by putting a "stop script" inside of an "if" inside of the "forever"-- it'll go "forever" until the condition of the if is met, then hit the stop script & stop.

For instance try this script (starting from a blank project with just the cat):

when greenflag clicked
  forever
    move 10 steps
    if on edge, bounce
    if (( distance to mouse-pointer ) < 20)
        stop script

The cat then moves back and forth forever, but stops when the mouse pointer gets close enough.

<3

Offline

 

Board footer