Category:Events

Triggers a sequence of blocks to run when a specific sprite is clicked.

Sometimes code should only be run if an event happens. In this case, when a sprite is clicked, the blocks attached under the event block will begin to run sequentially. If the costume block is used here, the code will run whenever any sprite with the matching costume is clicked.

This block has a drop-down menu with “when” and “while” options. “When” a sprite is clicked, the code will only run once. “While” a sprite is clicked, the code will run over and over again until the sprite stops being clicked on.

Parameters

Name Description
when/while Determines if the code is run when the sprite is clicked (runs once at a time) or continuously while the sprite is clicked
sprite The sprite or sprite group being clicked

Tips

  • If you want something to happen only to the individual sprite being clicked, use the this / other sprite block in any of the following actions.

Found a bug in the documentation? Let us know at documentation@code.org