Zmiany

Skocz do: nawigacji, wyszukiwania

Introduction 3 - Glossary of basic Scratch 2.0 blocks

Dodane 6514 bajtów, 09:09, 7 lip 2015
/* Operators */
[[Plik:M_3_1.JPG|center]]
The category '''Motion ''' groups sprite movement blocks, used for their movement, rotation and reading current data related to a sprite’s location. These are very often used basic blocks. Below is a description of all the blocks in this category.
[[Plik:M_3_2.JPG]]
[[Plik:M_3_24.JPG|center]]
The '''Looks ''' category is a collection of sprite appearance blocks concerning costume, size, visibility, etc. Some of these blocks are used very often. Below is a description of most blocks in this category.
[[Plik:M_3_25.JPG]]
For a limited time displays in a speech bubble the text shown in the edit box. This means stopping the script execution for a specified number of seconds. A variable can also be dragged into the edit box or an expression can be built in it – often to connect the displayed information we use the '''join ''' block.
'''Example:'''
[[Plik:M_3_26.JPG]]
Displays in a speech bubble the text shown in the edit box and does not stop the script execution. Consequently, further instructions are executed, which might cause the bubble’s quick disappearance. A variable can also dragged into the edit box or an expression can be built in it – often to connect the displayed information we use the '''join ''' block.
'''Example:'''
[[Plik:M_3_27.JPG]]
For a limited time displays in a thought bubble the text shown in the edit box. This means stopping the script execution for a specified number of seconds. It works in the same way as the '''say ''' command, but a different kind of information is displayed. A variable can also be dragged into the edit box or an expression can be built in it – often to connect the displayed information we use the '''join ''' block.
'''Example:'''
[[Plik:M_3_28.JPG]]
Displays in a thought bubble the text shown in the edit box and does not stop the script execution. Consequently, further instructions are executed, which might cause the information’s quick disappearance. It works in the same way as the '''say ''' command, it is just a different kind of bubble. A variable can also be dragged into the edit box or an expression can be built in it – often to connect the displayed information we use the '''join ''' block.
'''Example:'''
[[Plik:M_3_39.JPG]]
Name of the currently displayed background. It can be used as an argument in expressions.
Checking the checkbox on the left displays the background name on the stage.
[[Plik:M_3_45.JPG]]
Stops all currently played sounds.
==Pen==
[[Plik:M_3_76.JPG]]
This block allows us to define and broadcast a message. We can choose the message name from the drop-down list or define a new message using the '''new message... ''' option available when we expand the list.
[[Plik:M_3_77.JPG]]
'''Example:'''
 
[[Plik:M_3_96.JPG]]
 
 
The answer provided by the user, as the result of the block '''Ask and wait'''. It can be used as an argument in expressions. Checking the checkbox on the left displays the answer provided on the stage. Example: See the description of the '''Ask and wait''' block.
 
[[Plik:M_3_97.JPG]]
 
Checks if the key selected from the drop-down list has been pressed. This block is used most often in conjunction with one of the following blocks: '''if, repeat until, wait until'''.
 
'''Example:'''
 
[[Plik:M_3_98.JPG]]
 
Checks if the left mouse button has been pressed. This block is used most often in conjunction with one of the following blocks: '''if, repeat until, wait until'''.
 
'''Example:'''
 
[[Plik:M_3_99.JPG]]
 
The current value of this x and y coordinate of this mouse cursor. They can be used as an argument in expressions. These coordinates are also displayed below the lower right hand corner of the stage.
 
'''Example:'''
 
[[Plik:M_3_100.JPG]]
 
Current time in seconds since the last click of the green flag or execution of the block '''reset timer'''. It can be used as an argument in expressions. Checking the checkbox on the left displays the time on the stage.
 
'''Example:'''
 
[[Plik:M_3_101.JPG]]
 
Resets the timer count. The values provided by the timer block will be counted from zero again.
 
'''Example:'''
 
[[Plik:M_3_102.JPG]]
 
The current value selected in the first drop-down list, pertaining to the sprite selected from the second list or the stage. We can select the x or y coordinate, direction, costume number, name or size. For the stage we can choose the number or the name of the background. The returned value can be used in expressions.
 
'''Example:'''
 
[[Plik:M_3_103.JPG]]
 
 
==Operators==
 
[[Plik:M_3_104.JPG|center]]
 
The category of '''Operators''' groups blocks of basic arithmetic operations, logical operations and various functions (both arithmetic and on texts). All blocks in this category are used as arguments for other blocks. Below is a description of most blocks in this category.
 
[[Plik:M_3_105.JPG]]
 
Blocks of the four basic arithmetic operations (addition, subtraction, multiplication, division). In the edit boxes arguments should be provided (which may be manually entered numbers, the value of a variable or the result of another action, so blocks can be embedded). A built arithmetic expression should be used as an argument for another block, e.g. to determine the value of a variable or a logical expression.
 
'''Example:'''
 
[[Plik:M_3_106.JPG]]
 
Draws a number from a specified range. In the edit box we should specify the lower and upper range of the random number to be picked. The block should be used as an argument for another block.
 
'''Example:'''
 
[[Plik:M_3_107.JPG]]
 
[[Plik:M_3_108.JPG]]
 
Comparison blocks (less than, equal to, greater than). In the edit boxes we should specify values to be compared. We can enter specific values in the edit fields, most often one of the arguments is the value of a variable or a value read with the use of another block (e.g. a coordinate of a sprite’s position on the stage). This block is used most often in the following instructions: '''if, repeat until, wait until'''.
 
'''Example:'''
 
[[Plik:M_3_109.JPG]]
 
The blocks used to build complex logical expressions (conjunction – both conditions are true, alternative – one of the conditions is true, negation – contradiction). Insert the matching blocks returning Boolean values (true or false) in argument boxes. Blocks are used most often in the following instructions: '''if, repeat until, wait until'''.
'''Example:'''
 
[[Plik:M_3_110.JPG]]
 
The block is used to connect two strings of text into one. Usually one of the arguments is the entered text, and the other a value returned by another block. The block is often used as an argument in the '''say''' and '''think''' blocks.
 
'''Example:'''
 
[[Plik:M_3_111.JPG]]
 
The value is the remainder of the division of the first argument by the second. The block is often used as an argument in arithmetic and logical operations.
 
'''Example:'''
 
[[Plik:M_3_112.JPG]]
 
The value is the argument rounded off to the nearest integer – according to rounding rules, i.e. 0.5 and more is rounded up, otherwise down. The block is often used as an argument in other blocks.
 
'''Example:'''
 
[[Plik:M_3_113.JPG]]
 
The value is the result of the function selected from the drop-down list for the argument specified in the edit box. From the drop-down list we can select the following functions:
[[Plik:M_3_114.JPG]]
 
The block is often used as an argument in other blocks. Functions such as '''floor''' (always round down) and '''ceiling''' (always round up) may require explanation.
 
'''Example:'''
 
[[Plik:M_3_115.JPG]]
 
==Stage blocks==
 
[[Plik:M_3_116.JPG|center]]
 
The stage, like sprites, can have its own scripts. To create scripts for the stage we need to select it as the active object in the bottom right corner of the screen – the area for managing sprites and the stage. The choice of available blocks will change then – many of them apply only to sprites and may not be used in stage scripts. Differences are described below.
 
1. The '''Motion''' category
 
There is no block in this category, the stage cannot be moved or rotated.
 
 
2. The '''Looks''' category
Most changes are in this category. The stage can have multiple backgrounds, just like a sprite can have multiple costumes. There are blocks associated with the change of background and information about the selected background. The most important of these are the following:
 
[[Plik:M_3_117.JPG]]
 
 
3. The '''Sounds''' category
The blocks are the same, but when we play audio files they relate to the sounds assigned to the stage in the '''Sounds''' tab.
 
4. The '''Pen''' category
In this category, there is only one block for the stage – '''clear'''.
 
 
5. The '''Data''' category
 
The same as for sprites. The only difference is that we can only create variables available for all sprites.
 
 
6. The '''Events''' category
The same blocks as for sprites.
 
7. The '''Control''' category
The same blocks as for sprites.
 
8. The '''Sensing''' category
 
The same blocks as for sprites. There are no blocks for sprites interacting with other objects and colours ('''is touching, is touching the colour, the colour is touching the colour, distance from''')
 
9. The category '''Events'''
 
The same blocks as for sprites.
223
edycje