Basically, Cloning Sprites is an important activity that forms part of many Scratch games. This article explains cloning sprites until a condition is satisfied. Also, it explains how to delete a clone. The following project demonstrates cloning sprites.
Command Blocks used in the Project
The following command blocks are used in cloning sprites.
At first, we use the event command so that the script can start when user click on the green flag. After that, a forever control block executes the inner blocks always until the user clocks on the stop icon. Further, we the Variables and Operators blocks to create a variable x1 and to check when reaches the value greater than 50.
Further, we use the control block repeat…until to check the value of x1 and to repeat the command inside it. As can be seen, we can increment the value of x1 by using the variables block command.
The following steps have been used to create this application. Finally, we create the clone of the sprite used and also turn it for some random value of degree. Since, we need to place the cloned sprite at another position, so we make it to glide at some random position. Otherwise, the cloned sprites will overlap each other.
Since, the above mentioned procedure will make an infinite number of clones of the sprite. Therefore, we must delete them. Hence, we create another set of sprite blocks that will recognize a sprite. After that it will check the value of the variable x1 and repeats the following actions. It decrements the value of x1 by 1 and deletes a clone. The following figure shows the complete script.