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

#1 2010-05-27 17:31:57

infinitum3d
Scratcher
Registered: 2009-05-10
Posts: 100+

Is it possible to interrupt a command? If not, what are alternatives.

I'm currently using the glide ___ secs to x__ y__ to have my 'player' sprite move to my mouse pointer when I click the stage.

It works great.

Now I want to add walls to 'block' the player's movement.  Is there any way to interrupt the "glide to" command to perform collision detection?

My current thinking is a hack. Instead of having the sprite glide all the way to the mouse pointer, have it glide one pixel at a time, and do my collision detection one pixel at a time, possibly using the repeat until command(?).

While I think this would work, it seems like a HUGE lag would occur.

There has to be a better option.

Thanks!


My STAGE script:


<when[ STAGE ]clicked>

<broadcast[ glideToMousePointer ]>



My PLAYER_SPRITE script:

<when I receive[ glideToMousePointer ]>

<glide( 1 )secs to x sad  <mouse x> )y sad  <mouse y> )>

Last edited by infinitum3d (2010-05-27 17:36:30)

Offline

 

#2 2010-05-27 17:46:49

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: Is it possible to interrupt a command? If not, what are alternatives.

Unfortunately, there is no way to interrupt any command. Your only alternatives are to repeat something persistently until a clause is no longer true.

Offline

 

#3 2010-05-27 18:06:58

infinitum3d
Scratcher
Registered: 2009-05-10
Posts: 100+

Re: Is it possible to interrupt a command? If not, what are alternatives.

Hmmmm.... Ok, thanks Coolstuff! I'll have to figure out a workaround then. Something to replace "Glide to". . .

Offline

 

#4 2010-05-27 19:20:20

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

Re: Is it possible to interrupt a command? If not, what are alternatives.

http://scratch.mit.edu/projects/fg123_tests/1080909

Hope that helps!


Hai.

Offline

 

Board footer