Discuss Scratch

lemonpretzel
Scratcher
11 posts

Sense which color sprite is touching

How would you sense which color a sprite is touching? So far, I figured out that you can input “-” and the base ten version of the hexadecimal color in the “touching color _?” block. For example, FFFFFF would be “-16777215”. But, is there a way to find out exactly which color it is touching, rather than manually trying all different colors?

Last edited by lemonpretzel (May 11, 2013 02:10:05)


Check out my Android app - Manage It! It helps you keep track of everything you need to do, conveniently reminding you of due dates and letting you postpone them. Play Store (Android)
andre_rifaut
Scratcher
100+ posts

Sense which color sprite is touching

Etoys (made on top of Squeak, just like Scratch 1.4 was) allows to use color variables, i.e. variables that handle colors.
This is not allowed in Scratch.

You should try to modify your design and redraw your sprites so that only 2 or 3 colors have to be tested.

As one said: the beauty of the code design wil be reflected in the beauty of the application. The basic idea of Twitter is made with a simple design. May be this way of thinking is made easier with Scrath than with other languages ?
JoshyRobot
Scratcher
25 posts

Sense which color sprite is touching

lemonpretzel can you show me how to test all different colors? I'm need it to make my snapshot program!

No
Alberknyis
Scratcher
1000+ posts

Sense which color sprite is touching

You HAVE to check all the colours. There's no workaround.

stop [all v] ::stack
digthebone
Scratcher
500+ posts

Sense which color sprite is touching

forever

if <touching color [#ff0088] ?> then

end

end
then you will want to click that color then click the color you want it to be like you can put a
move () steps
block and hover you mouse over it to make the color blue. Hopefully you know what i mean.

Digthebone

I make stuff. And I am always digging for new idea's.




Craftwithcookies
Scratcher
84 posts

Sense which color sprite is touching

Mazin321
Scratcher
2 posts

Sense which color sprite is touching

I know. I did it and it worked,all you have to do is make 3 vars and 1 list and do this:
put all the colors in the color list(the list you made) ex.#000000 for black. If you miss a color the detecting may run forever.

var3 = 0
var1 = false
repeat until <(var1) = [true]>
set [var2 v] to (item (var3) of [colors v])
set [var1 v] to <touching color (var2) ?>
end
set [var1 v] to(var2)

Last edited by Mazin321 (Feb. 3, 2016 16:50:32)

Mazin321
Scratcher
2 posts

Sense which color sprite is touching

Lol
Run {{say(join (#1) (#2)(#3)(#4)(#5)(#6)::operators)} input names: (#1)(#2)(#3)(#4)(#5)(#6):: grey ring} with inputs: [This][is][a][block][from][snap] ::control
Invisible_Factory
Scratcher
500+ posts

Sense which color sprite is touching

Mazin321 wrote:

Lol
Run {{say(join (#1) (#2)(#3)(#4)(#5)(#6)::operators)} input names: (#1)(#2)(#3)(#4)(#5)(#6):: grey ring} with inputs: [This][is][a][block][from][snap] ::control
Please don't necropost, the topic is over a year old.

Currently, I have ~860 posts.
I am a scratcher who used to be really active on the forums 5 or 6 years ago, I basically quit scratch since then but I still check out the website from time to time. Do not expect asap replies because scratch is really at the back of my head

Powered by DjangoBB