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

#1 2008-05-03 20:46:33

alejandrofalca
Scratcher
Registered: 2007-07-16
Posts: 26

help on stopping a sprite accurately

Im trying to do a game where a sprite is supposed to stop when it touches a black frame, it works when you just touch the arrows once,but when you leave it pressed it just keeps moving,and gets out of the frame,so it would be extremely easy to cheat.
This is what Im currently doing:
<when green flag clicked>
<forever if><touching color[ black
<turn cw( 90 )degrees>
<move( 5)steps>

Offline

 

#2 2008-05-04 02:27:28

JSO
Community Moderator
Registered: 2007-06-23
Posts: 1000+

Re: help on stopping a sprite accurately

So i suppose you have your movement script somewhere else?

I think it will be best to do this:
[blocks]
<when green flag clicked>
<forever>
   <if> touching color black
      <turn cw( 90 )degrees>
      <move( 5 )steps>
   <else>
      movement: will stop when touching black
   <end>
<end>
[/blocks]

Last edited by JSO (2008-05-04 02:28:37)


http://oi48.tinypic.com/2v1q0e9.jpg

Offline

 

#3 2008-05-04 03:36:56

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

Re: help on stopping a sprite accurately

Have a look at the way the pacman is constrained in the demo that comes with scratch - it uses a colour sensor that prevents the pcaman from moving forwards if the sensor is touching the wall - meaning the main sprite stops without overlapping the wall.


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 2008-05-05 20:35:47

alejandrofalca
Scratcher
Registered: 2007-07-16
Posts: 26

Re: help on stopping a sprite accurately

thanks for the help!Ill be able to finnish my game

Offline

 

Board footer