<< Chapter < Page | Chapter >> Page > |
A moonscape background from the gallery was used for the project shown in Image 4 .
You control the behavior of a sprite by writing one or more scripts that belong to the sprite. In reality, each script is an event handler ofsorts. Usually you will have one event handler that executes when the user clicks the green flag at the top right in Image 6 . This is particularly true if any special initialization code is required for the sprite, such assetting the current costume to a particular costume, for example.
In addition to the green-flag script, you can also write scripts to handle mouse events, key events, and a special type of event that fires when one spritebroadcasts a message to one or more other sprites. Therefore, Scratch projects are not only sprite-based; they are also event-based. These arerelatively advanced concepts in most programming environments. However, Scratch was designed in such a way as to make it easy to write event-handlerscripts to control the behavior of sprites.
Creating Scratch programs involves very little typing. Instead, scripts are created by constructing stacks of blocks, where each block imparts somespecific behavior to a sprite or to the stage. For example, the project being developed in Image 6 has a stage, (which is always the case) but doesn't yet have any sprites. The stage is represented by the rectangularthumbnail image in the bottom right area of Image 6 . Any sprites that are added to the project would also appear as thumbnail images in that same area.I will refer to this area as the sprite list area.
The physical process for writing a script is as follows:
You will learn the details of such operations in future modules.
Selection of the other two tabs showing at the top of the center pane in Image 6 exposes the controls for importing, editing, and creating costumes and backgrounds, as well as recording and/or importing sound files to be used asmusic and sound effects.
Despite the fact that Scratch has amassed a huge following since its Beta release on March 4, 2007, in my opinion, the language isn't a particularly goodlanguage from a computer science viewpoint. Of the ten or fifteen programming concepts that most computer science professors consider to befundamental to good programming, Scratch supports only a few. Those few include:
Notification Switch
Would you like to follow the 'Teaching beginners to code' conversation and receive update notifications?