Discuss Scratch

de_melk_lord
Scratcher
22 posts

Sprite affecting other sprites

I need to make it so that a sprite will only do something if another sprite is touching a certain color. I searched for a while for a way to do this but I’m kind of stupid so I’m going here to ask people who actually know what they’re doing.
Modz31
Scratcher
72 posts

Sprite affecting other sprites

The sprite we're checking if touching a certain color:
when green flag clicked
forever
wait until <touching color [#2b419c] ?>
broadcast [touched v] and wait
end

Other sprite:
when I receive [touched v]
do something
de_melk_lord
Scratcher
22 posts

Sprite affecting other sprites

Thanks a lot, but I need to make it so that when the sprite does something, it checks weather or not the other sprite is touching the color.
SpyCoderX
Scratcher
1000+ posts

Sprite affecting other sprites

de_melk_lord wrote:

Thanks a lot, but I need to make it so that when the sprite does something, it checks weather or not the other sprite is touching the color.
Then you can do this:

For the sprite that is touching the color:
when flag clicked
forever
set [touching v] to <touching color [#ed8840] ?> //The "touching" variable should be a "For all sprites" variable, not a "For this sprite only" variable.
end

For the sprite that is doing something:
if <(touching) = [true]> then
do smth //Will only run if the first sprite is touching the color.
end

If something doesn't make sense, please let me know!
Hope this helps!
ScrubberLord
Scratcher
12 posts

Sprite affecting other sprites

when green flag clicked
if <> then
<touching [ v] ?>
broadcast [ v]
end




when I receive [ v]
change [ v] effect by (25)

Powered by DjangoBB