Discuss Scratch

Guy_Shaggy
New to Scratch
3 posts

Trouble with broadcast and receive message

I'm coding a simple game, where the object is to touch the blue square with the yellow circle, while avoiding the red circle.

I tried to use the broadcast message script to make my “level 1” sprite change costumes so that it says “level complete”.

As you can see, I managed to get the blue sprite (sprite 2) to change costumes, but I can't get the “level 1” (sprite 4) to change. Can anyone tell me what the problem with my script is? I tried putting the broadcast message on sprite 1, and the message received block on sprite 4 - which is the one I want to change.

https://scratch.mit.edu/projects/175645527/

Thanks!
PhoenixDragonBlue
Scratcher
100+ posts

Trouble with broadcast and receive message

Seems like it's working…

Guy_Shaggy
New to Scratch
3 posts

Trouble with broadcast and receive message

Phoenix, I'm trying to get the “level 1” (sprite 4) sprite in the top right to change to “level complete” when the sprite 1 touches sprite 3.

I've succeeded in getting sprite 3 to change (as you noticed), but not sprite 4.

(also noticed a mistake in my first post, the blue sprite is sprite 3, not sprite 2

Last edited by Guy_Shaggy (Sept. 23, 2017 15:51:43)

deck26
Scratcher
1000+ posts

Trouble with broadcast and receive message

The only broadcast of message1 I can see is not in a loop so it runs that code immediately after the green flag is clicked but a split second later it is finished. So unless sprite1 is touching sprite3 at the start it won't work. You need something like a forever loop or a wait until touching blue.
Guy_Shaggy
New to Scratch
3 posts

Trouble with broadcast and receive message

Thanks deck26, the forever loop fixed it!
ScratchyCat5100
Scratcher
29 posts

Trouble with broadcast and receive message

Guy_Shaggy wrote:

I'm coding a simple game, where the object is to touch the blue square with the yellow circle, while avoiding the red circle.

I tried to use the broadcast message script to make my “level 1” sprite change costumes so that it says “level complete”.

As you can see, I managed to get the blue sprite (sprite 2) to change costumes, but I can't get the “level 1” (sprite 4) to change. Can anyone tell me what the problem with my script is? I tried putting the broadcast message on sprite 1, and the message received block on sprite 4 - which is the one I want to change.

https://scratch.mit.edu/projects/175645527/

Thanks!
Use
broadcast [message1 v]
and use
when I receive [message1 v]
On other sprite. If you want to wait until receive done, use this block:
broadcast [message1 v] and wait
That will be better! View remix for bug fixes! Click the button!

Last edited by ScratchyCat5100 (Sept. 23, 2017 16:46:33)

Powered by DjangoBB