Are <touching [color]> blocks efficient?

The title is the question.

no they cause lag. but they are the way to tell if the sprite is touching that color

TOUCHING COLOR isn't as bad as it once was; Jens found a way to speed it up. But it's better if you can avoid it.

  • Is the color of interest part of another sprite's costume? Make another sprite whose costume will be just the part of the first sprite's costume that's the color of interest, and then attach the new sprite to the first sprite using nesting sprites (look it up in the manual). Then check if you're touching the new sprite. (If you clone the original (anchor) sprite, the attached (part) sprite will be cloned too.)

  • Is the color part of the stage's background, or drawn on the stage by your program at a fixed position? See if you can test your sprite's position to determine if it's in the region of interest instead of using TOUCHING at all.

  • If the color is drawn on the stage, but at an unpredictable position, maybe you can use the AT block in the Sensing category ((R-G-B-A) AT (MYSELF)). This doesn't do exactly what TOUCHING COLOR would do, because it checks only the color at your sprite's rotation center, not whether any part of your sprite is touching the color. But for some purposes it's close enough.

I mainly wanted to know if it was making something laggy. I just got rid of them entirely in the project. It would have been for option two, with a circle of the color.

I got a consistent 1.2-1.4 seconds with the same setup as you.

in games, it is recommended to use sprites rather than <if touching[colour]>, because it is inefficient, and the sprite tends to show a "sinking" effect

Could you post a picture of that?


You live in Antarctica? That's so cool!

I just checked, and yeah, her location thing says "Antarctica". That's rare.

What people put in that profile field isn't necessarily true...

Yes. I think the only thing that has to be correct is the email address.

i did see that bug but i went to take a screenshot of it and it seems to be fixed now.... sorry my bad :slightly_frowning_face:

Do you remember what version you saw it in? If 6.9.2, unless there's a hidden 4th number, it couldn't have been fixed.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.