Discuss Scratch

ItchyCatIII
Scratcher
500+ posts

Color () touching color () block doesn't work correctly

I was trying to create a project, but it depends on the
<color [ ] is touching [ ] ?>
block.

I notice that this block has a problem. If I have this block created on one sprite, it may return false when really the condition is true.

For example, I have a black square on the default stage, therefore, it is touching white. If I wrote
<color [#000] is touching [#ffffff] ?>
it would turn up true if it were on the scripts of the black sprite.

But, if I had a green sprite somewhere else (on the same project, of course), and the black square was still there touching the stage, on the green sprite's scripts, that condition would turn up as false.

It would still be true on the black sprite or the stage, just not in the scripts of the green sprite.

Obviously, there is a workaround (this is on the black sprite's scripts):

when green flag clicked
forever

if <color [#000] is touching [#ffffff] ?> then

set (variable) to [1]
else
set (variable) to [0]
end

end

And then, on the green sprites scripts, I could use:
<(variable) = [ 1]>
as a replacement, but, obviously most Scratchers will not know that there is this glitch, so they will not know to do that.

Don't you just hate when people advertise in their signatures (and raisin cookies that look like chocolate chip ones. That's just not okay).

#BringItBack
stickfire-test
Scratcher
100+ posts

Color () touching color () block doesn't work correctly

The problem is that the block is ambiguously worded - it actually means
(color [#000000] on this sprite is touching [#ffffff] :: sensing)


ItchyCatIII
Scratcher
500+ posts

Color () touching color () block doesn't work correctly

stickfire-test wrote:

The problem is that the block is ambiguously worded - it actually means
(color [#000000] on this sprite is touching [#ffffff] :: sensing)

Then I think they should change the block to that.

Last edited by ItchyCatIII (Aug. 12, 2015 21:49:39)


Don't you just hate when people advertise in their signatures (and raisin cookies that look like chocolate chip ones. That's just not okay).

#BringItBack
drmcw
Scratcher
1000+ posts

Color () touching color () block doesn't work correctly

That's not a bug but how it is supposed to work. The first colour has to be in the costume of the sprite that is running the script with the touching block and that colour has to be touching the second colour to return true.

So in your example the green sprite has no black so will always be false for black touching white because there is no black in a green sprite.

Edit: It's not ambiguous, would you expect
<touching [sprite v] ?>
to always return true because sprite would always be touching sprite or
move (10) steps
to move all sprites 10 steps?

Last edited by drmcw (Aug. 12, 2015 21:55:30)


10 !
ScratchVaders or Galaga?
Maybe Eliza can help you decide?
daemys
Scratcher
100+ posts

Color () touching color () block doesn't work correctly

The computer doesn't work with colors, it works with numbers. The black color is encoded with number 0, The white is 16777215. So there are nearly 17 million of colors and shades. Human eye just can't tell them apart. For your, mine and any other person's eye colors 0 and 1 seem identical. But for computer those are totally different as 0 and 16777215.

Powered by DjangoBB