Scratch hat blocks → Pytch decorators¶
Done via Python decorators. E.g.,
@pytch.when_I_receive("Play_One_Point")
def prepare_to_play(self):
# ... do stuff ...
The available decorators are:
- pytch.when_green_flag_clicked¶
Ask Pytch to run the decorated method whenever the green flag is clicked by the user.
- pytch.when_key_pressed(key_name)¶
Ask Pytch to run the decorated method whenever the user presses the given key.
- pytch.when_this_sprite_clicked¶
Ask Pytch to run the decorated method whenever the user clicks (or taps) on the sprite. Should be used only for Sprites (not your Stage).
- pytch.when_stage_clicked¶
Ask Pytch to run the decorated method whenever the user clicks (or taps) on the stage. Should be used only for your Stage (not Sprites).
- pytch.when_I_receive(message_string)¶
Ask Pytch to run the decorated method whenever somebody broadcasts the given
message_string
.
- pytch.when_I_start_as_a_clone¶
Ask Pytch to run the decorated method whenever a clone of the Sprite is created. Within the method,
self
refers to the newly-created clone.