Discuss Scratch

Iphagenia
Scratcher
16 posts

Does the <color () is touching color ()?> work with pen?

I'm trying to make a 100% pen project that senses whether or not a color is touching another color. It wasn't working, so I made a test where I drew a large black dot and a large red dot overlapping, with pen. Then I used this:
<color [#ff0000] is touching [#000000] ?>
and it turned up false! I rechecked over and over again to see if I hadn't droppered the colors correctly, but I am 100% sure that I did. Does the
 <color [#ff0000] is touching [#000000] ?> 
block not work for pen?
awesome-llama
Scratcher
1000+ posts

Does the <color () is touching color ()?> work with pen?

It works. I just tested it.

I'm not sure what would be causing the issue, without seeing more of the project.
I have three things you might want to check:
- Is the sprite hidden? It needs to be showing to detect colours. Use a set ghost effect if you want to not see it.
- Is it detecting after the pen is drawn? Maybe you are drawing the black parts that you are wanting to detect later in the frame.
- What is the red from? If it is a sprite with red, that would work. Potentialy, you are trying to detect whether a red pen stroke is touching black, which would not work.
Iphagenia
Scratcher
16 posts

Does the <color () is touching color ()?> work with pen?

The sprite is showing when it's detecting. Since it is a 100% pen project, there is no mass to the sprite, you could say. So yes, I am trying to detect whether or not a red pen stroke is touching a black one. Are you saying that you cannot detect when two pen strokes are touching?
awesome-llama
Scratcher
1000+ posts

Does the <color () is touching color ()?> work with pen?

You can't detect when two pen strokes are touching, however you can do the detection when drawing the stroke. As you draw the stroke, the rendering sprite can be used to detect it as it moves. You may have to make the sprite switch costume or change size to get the right detection, or potentially draw with smaller steps to detect it for longer strokes. It's not impossible to workaround.
deck26
Scratcher
1000+ posts

Does the <color () is touching color ()?> work with pen?

My understanding is that the block you're using needs the first colour to be on the costume of the sprite. I don't think you can detect a red pen tocuhing a black line with that block unless the costume has a red part touching the black line.

Of course i may be wrong.
Iphagenia
Scratcher
16 posts

Does the <color () is touching color ()?> work with pen?

Thanks to you both! I think what I shall do is this: Make a new script that says
when green flag clicked
forever
if <touching color [#ff0000]?> then
set (touching red?) to [true]


else
set (touching red?) to [false]
end
end
and then whenever I want to know if
 <color [#ff0000] is touching [#000000] ?> 
I'll just use
<(touching red?) = [true]>
Do you all think that would work?
Iphagenia
Scratcher
16 posts

Does the <color () is touching color ()?> work with pen?

Hmmm… I tried that and it didn't work. I think the problem is that everything is constantly redrawing itself, so there isn't ever a chance for anything to touch anything else. I think the solution is going to have to be to sense the exact x- and y- positions of the pen- drawn moving character every second, like so:
when green flag clicked
forever
if <(y position) = [130]> then
set (touching ground?) to [true]


else
set (touching ground?) to [false]
end
end
This is going to take a while -_-

Powered by DjangoBB