Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Sprite touching another Sprite
- atosise
-
8 posts
Sprite touching another Sprite
Hello all,
I am new to Scratch and I have a generic question. Not sure if this has been posted again.
I am using this <sprite touching sprite> choice but it does not seem to work as expected.
I am noticing that it only works if the 2 sprites are touching each other on their center. What I need though is for the 2 sprites to touch anywhere.
I also tried the color variation, but it seems like my background changes my sprite's brightness in several places so I cannot keep track of the color.
Any suggestions/ideas?
Thank you
I am new to Scratch and I have a generic question. Not sure if this has been posted again.
I am using this <sprite touching sprite> choice but it does not seem to work as expected.
I am noticing that it only works if the 2 sprites are touching each other on their center. What I need though is for the 2 sprites to touch anywhere.
I also tried the color variation, but it seems like my background changes my sprite's brightness in several places so I cannot keep track of the color.
Any suggestions/ideas?
Thank you

- atosise
-
8 posts
Sprite touching another Sprite
Thank you for the answer.
Does distance to counts from the center of the sprite (like touching does) though?
Does distance to counts from the center of the sprite (like touching does) though?
- Zurdax
-
100+ posts
Sprite touching another Sprite
Actually the touching block does not only work for the center, but for the whole sprite. They can touch anywhere, so it should work for you. Maybe you interpret the block wrong: It means that at least one pixel has to overlap. If they are right next to each other, but nothing overlaps, than it will not detect that.
- atosise
-
8 posts
Sprite touching another Sprite
Thank you for your answers.
Most people tell me it should work, so I am guessing I do something wrong.
Not sure if the change of costumes bugs my code.
I say if frog's tongue touches dragonfly.
But frog's tongue have 8 costumes below it (tongue1->tongue8) and it constantly changes.
Maybe there is a bug there.
Most people tell me it should work, so I am guessing I do something wrong.
Not sure if the change of costumes bugs my code.
I say if frog's tongue touches dragonfly.
But frog's tongue have 8 costumes below it (tongue1->tongue8) and it constantly changes.
Maybe there is a bug there.
- Zurdax
-
100+ posts
Sprite touching another Sprite
You could share the project, so we can try finding the bug! 

- atosise
-
8 posts
Sprite touching another Sprite
Thanks. Here it is -> https://scratch.mit.edu/projects/875601919/
- Zurdax
-
100+ posts
Sprite touching another Sprite
Found the problem:
This block glide block waits 10 seconds until the next bit of code is executed. That means the fly only checks if it's touching the tongue every 10 seconds.
Another suggestion:
In your tongue script, you can change it so the tongue doesn't stay out:
Change this
This block glide block waits 10 seconds until the next bit of code is executed. That means the fly only checks if it's touching the tongue every 10 seconds.
My suggestion would be to to use this code:
Another suggestion:
In your tongue script, you can change it so the tongue doesn't stay out:
Change this
to this
I hope this helps!
- atosise
-
8 posts
Sprite touching another Sprite
Wow, I would never think of glide haha
Thank you very much for your time!
I' ll check it out as soon as I return from work.
Cheers!
Thank you very much for your time!
I' ll check it out as soon as I return from work.
Cheers!

Last edited by atosise (July 19, 2023 13:16:22)
- Discussion Forums
- » Help with Scripts
-
» Sprite touching another Sprite