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

#1 2012-10-16 15:58:51

ccheney
New Scratcher
Registered: 2012-10-15
Posts: 4

Sprite stuck on Glide after a broadcasted event

I'm expecting the sprite to always glide to x/y on line 4 in the first thread which works great. However, when line 3 and 4 are triggered in the second thread, line 7 and 8 do not execute.

It seems to be stuck on glide from thread 1 line 4 and the sprite never executes line 7-8 from thread 2. It switches costume from line 5 in the second thread, waits 2 seconds, then switches costume from line 9 in the second thread but continues gliding.

How can I stop a glide after a broadcasted event?

Thanks for your help.


Thread 1
1 when key pressed
2    forever
3       go to x/y
4       glide 10s to x/y
5       switch costume
6       go to x/y
7       stop script
   
Thread 2
1 when flag clicked
2    forever
3        if touching sprite2
4           broadcast event
5           switch costume
6           wait 2s
7           hide
8           go to x/y
9           switch costume
10          show

Offline

 

#2 2012-10-16 16:11:51

ccheney
New Scratcher
Registered: 2012-10-15
Posts: 4

Re: Sprite stuck on Glide after a broadcasted event

That's pretty cryptic so here's a screenshot:

Edit: Can't insert images or links(new user) so copy and paste this url:

http://i.imgur.com/jeoNf.png

Offline

 

#3 2012-10-16 16:16:08

ccheney
New Scratcher
Registered: 2012-10-15
Posts: 4

Re: Sprite stuck on Glide after a broadcasted event

To add:

The sprite starts at the top of the screen and when you press the 1 key it glides towards the bottom. If it comes in contact with another sprite, thread 2 starts. It's supposed to change costumes, wait, then reset back to the top again.


(Can't edit posts, sorry for spamming)

Offline

 

#4 2012-10-16 16:48:25

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: Sprite stuck on Glide after a broadcasted event

http://i.imgur.com/jeoNf.png
It's okay. Anyway, there is only one way that I know of to stop a glide block, and that involves broadcasts. Anyway, here it is:

when I receive [gliding1 v]
if <(glide) = (1)>//Or whatever tells you if you should be gliding or not.
 glide (Filler) secs to x: (Filler) y: (Filler)
end
Just use [broadcast [gliding1 v] until done] if you need your sprite to do some gliding. Also, when you need to interrupt the gliding, just broadcast gliding1 again. Anyway, I hope that this helps!

Last edited by ErnieParke (2012-10-16 16:56:47)


http://i46.tinypic.com/35ismmc.png

Offline

 

#5 2012-10-16 22:37:31

ccheney
New Scratcher
Registered: 2012-10-15
Posts: 4

Re: Sprite stuck on Glide after a broadcasted event

Thanks for trying to help but I don't quite understand what your script is doing  sad

Offline

 

#6 2012-10-17 06:12:16

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: Sprite stuck on Glide after a broadcasted event

ccheney wrote:

Thanks for trying to help but I don't quite understand what your script is doing  sad

It's okay! The script I made is supposed to allow you to be able to interrupt the glide block and to execute lines 7-8 of your second script.

Last edited by ErnieParke (2012-10-17 06:12:41)


http://i46.tinypic.com/35ismmc.png

Offline

 

Board footer