<< Chapter < Page | Chapter >> Page > |
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) and has a single sprite wearing a costume for a cat. The stage is represented by the rectangularthumbnail image in the bottom left 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, version 1.4 of the language wasn't a particularly goodprogramming language from a computer science viewpoint. Of the ten or fifteen programming concepts that most computer science professors consider to befundamental to good programming, Scratch v1.4 supported only a few. Those few include:
These are very important concepts but notably absent was programmer-defined procedures, functions, or methods. I am happy to report that v2.0 seems to haveresolved that deficiency.
Version 2.0 makes it possible for the programmer to create new blocks and to save those new blocks for use in ways that programmers in other languages useprocedures. I will have much more to say about this in a future module.
Notification Switch
Would you like to follow the 'Teaching beginners to code' conversation and receive update notifications?