Skip to content

Please update your browser

Your browser version is not supported by this site. CS First may not work properly. Learn more

2. Créer des clones

Transcript

Today’s starter project has a gray architect’s toolbox at the top. In this box are building piece sprites that the user of your software can use to create a building.

To allow someone to select a building piece sprite from the toolbox, you’ll need to program them so that: When a sprite is clicked, it creates a copy, or clone, of itself. The clone follows the mouse pointer until the mouse is clicked again. The clone stamps on the stage.

The next few videos will walk you through how to program the arch sprite. You will program the rest of the sprites on your own. First, create a clone. This clone will become what you stamp, so the building piece sprite can stay in your toolbox.

A “clone” is a copy of a sprite. The clone looks just like the original sprite and does whatever the sprite does. From the control menu, drag out the “create clone of” block. Click on the “create clone of” block to test what it does. It looks like nothing happens. If you click and drag the sprite away from the toolbox, however, then you’ll see that there’s a copy underneath it. For today’s project, clones should appear when the user clicks on the original sprite. Go to the event menu, drag out the “when this sprite is clicked” block, and place it above the “create clone of myself” block. To test, click the sprite to make a clone, then click and drag the sprite to move it aside. You should see the clone beneath the original sprite. Click on the stop sign to remove all the clones.

Then, drag the building block sprite back into its spot in the toolbox.

Now, it’s your turn: Make a clone of the sprite in the toolbox with the “create clone of” and “when this sprite is clicked” blocks.

arrow_backward Retour
Suivant arrow_forward
Instructions
  1. Créez une copie du lutin Élément de construction.
  2. Faites apparaître le clone lorsque l'on clique sur le lutin élément de construction dans la barre d'outils.