Discuss Scratch

StupidGenius
Scratcher
4 posts

How to get sprite to change costume when broadcast a message?

Hi so when you win my game, I have a message that says “You Win!” and I want it to change costume to a message that says a different message after waiting 2 seconds. I also want a sprite of a witch to appear after the 2 seconds. However, the screen would just be stuck at my “You Win” message. It wouldn't change costume and the witch doesn't appear. What am I doing wrong?
Link to project: https://scratch.mit.edu/projects/273876226/
Scratch-Minion
Scratcher
1000+ posts

How to get sprite to change costume when broadcast a message?

The problem is that when you win, you broadcast “win” again and again in a forever loop.
But you only want to broadcast “win” once.

The scripts that receive the broadcast “win” run until a break (eg. they have a wait block in them).
The scripts do not then continue as they restart when they receive another “win” broadcast.


Two possible solutions in the Sack sprite to only broadcast “win” once:

1) Add “stop this script” after broadcasting “win”.
(Also add “stop this script” after broadcasting “game over”.

2) Rather than a forever loop, repeat until boxes = 20 or hits = -5
123catmad
Scratcher
3 posts

How to get sprite to change costume when broadcast a message?

_meow_
limpingminnow
Scratcher
20 posts

How to get sprite to change costume when broadcast a message?

Try this:
Code Holder:
when green flag clicked
game
win
broadcast [win v]
Text:
when I receive [win v]
show
wait (2) secs
broadcast [witch v]
next costume
Witch:
when I receive [witch v]
show

Last edited by limpingminnow (April 5, 2020 21:33:16)

Squashyfishy
Scratcher
100+ posts

How to get sprite to change costume when broadcast a message?

when green flag clicked
broadcast [next]

when I receive [next]
next costume
stop [this script]
cosmosaura
Scratch Team
1000+ posts

How to get sprite to change costume when broadcast a message?

Closed to stop necroposts.

Powered by DjangoBB