Discuss Scratch

edwardodixoni
Scratcher
1 post

How do I make a sprite disappear when another sprite touches it?

In my story a big shape falls out of the sky and makes someone standing under it disappear. But I don't know how to do it without making the person disappear from the whole story. So I need to know how to make him vanish (with Hide) when the big shape touches him. Thank you.
thelucariokid
Scratcher
100+ posts

How do I make a sprite disappear when another sprite touches it?

when green flag clicked
wait until <touching [... v] ?>
hide
ethanbros
Scratcher
41 posts

How do I make a sprite disappear when another sprite touches it?

edwardodixoni wrote:

In my story a big shape falls out of the sky and makes someone standing under it disappear. But I don't know how to do it without making the person disappear from the whole story. So I need to know how to make him vanish (with Hide) when the big shape touches him. Thank you.
Use this.

when green flag clicked
show
wait until <touching [(insert name here) v] ?>
hide
cs24921
Scratcher
100+ posts

How do I make a sprite disappear when another sprite touches it?

I would try this:

Programming on your main character now:

when green flag clicked
forever

if <touching [Big Object v] ?> then
hide

end

end

Later, using broadcasting, you can make your character appear again. Or to reset, simply:

when green flag clicked
show

svarela11
New Scratcher
1 post

How do I make a sprite disappear when another sprite touches it?

thank you \
deck26
Scratcher
1000+ posts

How do I make a sprite disappear when another sprite touches it?

cs24921 wrote:

I would try this:

Programming on your main character now:

when green flag clicked
forever

if <touching [Big Object v] ?> then
hide

end

end

Later, using broadcasting, you can make your character appear again. Or to reset, simply:

when green flag clicked
show

Only if you stop the forever loop which is hiding it! Generally bad practice to hide or show in a forever loop and should never be necessary in my opinion.

Last edited by deck26 (Oct. 19, 2016 21:20:49)

lconaway
Scratcher
500+ posts

How do I make a sprite disappear when another sprite touches it?

Depending on what you want it to do, here are your options:

A. If you want it to disappear when it is touched and not come back

when green flag clicked
show
wait until <touching [sprite 1 v] ?>
hide

B. If you want it to disappear whenever it is touched but come back when not being touched

when green flag clicked
hide
forever
if <touching [sprite 1 v] ?> then
hide
else
show
end
end

Hope this helps!

Powered by DjangoBB