Discuss Scratch

amylaser
Scratcher
500+ posts

How the Touch-Sensing Block Senses Overlap

Hi all,

I was just wondering how the touch-sensing block works on a deeper level – does it only detect whether two sprites are overlapping, or does it go the extra mile and also detect whether the two sprites are actually touching in the sense that there are no other sprites in between them? As in, the two sprites both overlap and occupy consecutive layers in the Scratch Player?

Here are some pictures in case I wasn't being clear.

Two overlapping sprites: Two overlapping sprites with another sprite in the layer between them:


Thanks if anyone can explain. :-)

Last edited by amylaser (Oct. 10, 2016 19:12:13)

lconaway
Scratcher
500+ posts

How the Touch-Sensing Block Senses Overlap

I think that the first picture would count as touching, and the second picture wouldn't. I think it's because Scratch is not 3-dimensional so it assumes that if one sprite is in front of another they are actually touching, because it has no sense of depth and therefore wouldn't be able to tell if there was space between them or not.
However, if there is something between them, it can actually tell that they are not touching because–well, there's something between them.
Look at it this way–in the first one, is the color red touching the color orange (Ignoring the black outlines)? Yes. In the second one, is the color red touching the color orange? No.

Hope this helps!

Last edited by lconaway (Oct. 10, 2016 19:04:43)

amylaser
Scratcher
500+ posts

How the Touch-Sensing Block Senses Overlap

lconaway wrote:

I think that the first picture would count as touching, and the second picture wouldn't. I think it's because Scratch is not 3-dimensional so it assumes that if one sprite is in front of another they are actually touching, because it has no sense of depth and therefore wouldn't be able to tell if there was space between them or not.
-snip-

Ah well, you see, I tried it out in a project of mine, and it seems that the touch-sensing block still considers the sprites in the second picture to be touching, even though there is another sprite between them. Which is why I assumed that the touch-sensing block solely functions based off of sprite overlap – however, I'm really hoping that someone can prove me wrong about that, or give me a little more insight into how it works. :')

Last edited by amylaser (Oct. 10, 2016 19:11:37)

lconaway
Scratcher
500+ posts

How the Touch-Sensing Block Senses Overlap

amylaser wrote:

lconaway wrote:

I think that the first picture would count as touching, and the second picture wouldn't. I think it's because Scratch is not 3-dimensional so it assumes that if one sprite is in front of another they are actually touching, because it has no sense of depth and therefore wouldn't be able to tell if there was space between them or not.
-snip-

Hope this helps!

Ah well, you see, I tried it out in a project of mine, and it seems that the touch-sensing block still considers the sprites in the second picture to be touching, even though there is another sprite between them. Which is why I assumed that the touch-sensing block solely functions based off of sprite overlap – however, I'm really hoping that someone can prove me wrong about that, or give me a little more insight into how it works. :')
Hmm…I would have thought otherwise. Sorry, I can't answer to that. I thought it was the other way around. But why would you want someone to prove you wrong? Are you having trouble with the scripts?
eh6239qr
Scratcher
100+ posts

How the Touch-Sensing Block Senses Overlap

lconaway wrote:

I think that the first picture would count as touching, and the second picture wouldn't. I think it's because Scratch is not 3-dimensional so it assumes that if one sprite is in front of another they are actually touching, because it has no sense of depth and therefore wouldn't be able to tell if there was space between them or not.
However, if there is something between them, it can actually tell that they are not touching because–well, there's something between them.
Look at it this way–in the first one, is the color red touching the color orange (Ignoring the black outlines)? Yes. In the second one, is the color red touching the color orange? No.

Hope this helps!

This is rather contradictory since if the default scratch layout is 2D and has no depth then it wouldn't matter whether there is something between them since they are all on the same physical plane. I believe that the Layers are strictly for appearances. I also made this very simple program which shows that a sprite in between two sprites will not stop them from detecting each other.

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

Just drag the sprites around if you want to test it for yourself.
lconaway
Scratcher
500+ posts

How the Touch-Sensing Block Senses Overlap

eh6239qr wrote:

lconaway wrote:

*snip*

This is rather contradictory since if the default scratch layout is 2D and has no depth then it wouldn't matter whether there is something between them since they are all on the same physical plane. I believe that the Layers are strictly for appearances. I also made this very simple program which shows that a sprite in between two sprites will not stop them from detecting each other.

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

Just drag the sprites around if you want to test it for yourself.

Oh. Well, I guess that makes sense…but what about the color thing? Now I'm confused.
eh6239qr
Scratcher
100+ posts

How the Touch-Sensing Block Senses Overlap

lconaway wrote:

eh6239qr wrote:

lconaway wrote:

*snip*

This is rather contradictory since if the default scratch layout is 2D and has no depth then it wouldn't matter whether there is something between them since they are all on the same physical plane. I believe that the Layers are strictly for appearances. I also made this very simple program which shows that a sprite in between two sprites will not stop them from detecting each other.

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

Just drag the sprites around if you want to test it for yourself.

Oh. Well, I guess that makes sense…but what about the color thing? Now I'm confused.
I'm pretty sure that the block detects sprite collisions by looking at the actual size and location of both sprites. That is just an educated guess I could be very wrong.
lconaway
Scratcher
500+ posts

How the Touch-Sensing Block Senses Overlap

eh6239qr wrote:

lconaway wrote:

eh6239qr wrote:

lconaway wrote:

*snip*

This is rather contradictory since if the default scratch layout is 2D and has no depth then it wouldn't matter whether there is something between them since they are all on the same physical plane. I believe that the Layers are strictly for appearances. I also made this very simple program which shows that a sprite in between two sprites will not stop them from detecting each other.

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

Just drag the sprites around if you want to test it for yourself.

Oh. Well, I guess that makes sense…but what about the color thing? Now I'm confused.
I'm pretty sure that the block detects sprite collisions by looking at the actual size and location of both sprites. That is just an educated guess I could be very wrong.
You might be right. That's a good guess.

Powered by DjangoBB