Discuss Scratch

cnwstevens
New to Scratch
2 posts

Help sharing variables across sprites?

I think this might be my problem, but I'm not sure….

I have sprites appearing and moving across the screen. When an answer to a question is correct, I have my main sprite broadcasting a message to a specific sprite to initiate its script. However, I can't get my main sprite to recognize when different sprites are on screen.

For example: dragon on screen, answer correct, main sprite broadcasts ‘dragon’. ONLY dragon runs its script. Other sprites continue to do move toward the main sprite until their specific broadcast is made. When the ghost is on screen and an answer is correct, I want my main sprite to broadcast ‘ghost’, so only the ghost runs its specific script.

To try and code this, I wanted to make it where I set a variable named ‘visible’ to 0 or 1 to hide or show the sprite. This works on the dragon's script, but I'm at a loss on how to make my main sprite recognize if the dragon is visible or not.

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

Thanks in advance, and let me know if that explanation was clear as mud.
HenriStar8
Scratcher
100+ posts

Help sharing variables across sprites?

I had an ideia, what if you make a costume for every sprite and that sprite has nothing, when it's in that costume it hide, then you use that:
([costume# v] of [... v])
if the number of costume of that sprite is the one that hide, then it continue

Last edited by HenriStar8 (Aug. 27, 2021 17:43:12)


when I receive [Nothing to do v]
repeat until <get a thing to do>
Draw
Make games
...
end
cnwstevens
New to Scratch
2 posts

Help sharing variables across sprites?

It's worth a shot- thanks for the suggestion!

Powered by DjangoBB