Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Scratch/Lessons/Event Triggers

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

In order for the user to be able to interact with your Scratch project, you must use event triggers. Event triggers activate code when a specified event happens, such as a key being pressed or a button being clicked. Understanding event triggers is essential to creating a Scratch project. We will go over some event triggers here. The "When Green Flag Clicked" Block thumb|188x188px|The "When Green Flag Clicked" block At the top left of the stage is a green flag. In order for the Scratch program to start, this green flag must be clicked. 402x402px Using the "When Green Flag Clicked" block, you can make anything you want happen when the green flag is clicked. When the green flag is clicked, any "When Green Flag Clicked" blocks will trigger. For example, when the green flag is clicked, the cat sprite will wait for a second, move to the right, wait a second, then move to the left forever: 317x317px The "When Green Flag Clicked" block is certainly a useful block, but without other event triggers your users would not be able to interact with your program; they would only be able to start it. Let's take a look at some other event triggers. The "When This Sprite Clicked" Block thumb|213x213px|The "When This Sprite Clicked" block In order to create buttons and the like in your Scratch program, you must use the "When This Sprite Clicked" block. When the sprite is clicked, this block activates code. For example, whenever the cat sprite is clicked, it rotates clockwise fifteen degrees: 188x188px