Triggers a sequence of blocks to run when a specific sprite touches another specific sprite.
(Opens YouTube in new tab)
Sometimes code should only be run if an event happens. In this case, when a specific sprite touches another specific sprite, the blocks attached under the event block will begin to run sequentially. If the costume
block is used in either parameter, the event will check for touches between any sprites of the matching costume(s).
This block has a drop-down menu with “when” and “while” options. “When” a sprite touches another sprite, the code will only run once. “While” a sprite is touching another sprite, the code will run over and over again until the sprites stop touching.
Whenever the bee touches the bear, the bear will say “Ouch!”
While the bubble sprite is touching the soap sprite, it will grow bigger. When the bubble touches a rock sprite, it will “pop” and return to its original size.
Name | Description |
---|---|
when/while | Determines if the code is run when the sprite touches another sprite (runs once at a time) or continuously while the sprite is touching another sprite |
sprite | The sprite or sprite group of the sprites touching |
this / other sprite
block in the following actions to only affect the sprite that was touched.Found a bug in the documentation? Let us know at documentation@code.org