2

In Scratch, there are "When" blocks, such as when green flag clicked, when key space pressed, when this sprite clicked, and so on, but if I had a boolean, such as "touching color color", how would I put it in a "When" block like "When touching color color"?

4yl1n
  • 148
  • 1
  • 10

2 Answers2

1

You can use: When green flag clicked forever if touching color *color* then (your script here...)

You can also use: When green flag clicked forever wait until touching color *color*, (your script here...)

CatPerson
  • 137
  • 7
  • You can. Unfortunately, Scratch isn't sophisticated about how it handles this kind of infinite loop, and so this approach would be costly in terms of performance (i.e. it will slow the program significantly). That said, between the two, the "wait until" is a much better choice. – Peter Duniho Aug 21 '19 at 22:32
1

You may also consider using the event system: Broadcast a message when touching color and listen to that message in a when i receive message block.

enter image description here

This approach helps separating your code into meaningful parts. And it allows to do different things on different sprites/stages when an event occurs.

simon.ro
  • 2,984
  • 2
  • 22
  • 36