Skip to content

Please update your browser

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

Remarque : Ce thème n’a pas été mis à jour pour intégrer Scratch 3.0. Pour plus d’informations, voir cet article d’aide.
Transcription

This video, will show you how to use the saved data in your lists to replace stamps that have been cleared.

Click on the clear button to clear the stamps and then follow the rest of this video to make it work.

First, program the sprite to go to the first location in the list.

Drag out the glide block.

This block will move the sprite to a specific position.

Type zeroes in the boxes next to X and Y, then click on the block.

It should move to (0,0) which is the center of the stage.

Then, move the arched sprite back to where it should start.

To move to the X and Y position from the list, place the item of block in the X box.

Click the dropdown to make sure it references the X location of the list, not the Y location one.

Then, place another item of variable in the Y box.

Click the dropdown to make sure it references the Y list this time.

Click on the block.

The arch should go to the first location.

Place a stamp block under the glide block to make the sprite stamp itself.

Return the sprite back to the tool box.

Great!

But that code made the sprite go to the first position on the list and stamp then it stopped.

Next, you will code this so that it goes through the entire list.

To easily make your program repeat the same action over and over, use a repeat loop.

Place a repeat loop around the glide and stamp blocks.

Next, program the loop to run the correct number of times.

The number of times this loop runs should equal the number of items on your list.

To make the loop run the correct number of times, use the length of block.

It doesn't matter whether you use the X or Y list as they both contain the same number of items.

Run the code.

Since there are two items in this list, the sprite should move to specific spot and stamp then move to a second spot and stamp.

But, it doesn't seem to be doing that.

It just goes to the first place and stops.

Click the clear button and return the sprite to the tool box.

The sprite is going to the X and Y of item one, or the first item of the list.

The first time the loop runs, the sprite should stamp the first location.

The second time, the second location, etc.

To keep track of how many times the code has gone through the loop, add a variable.

Click make a variable.

This variable will count code loops, so call it something that makes sense like count.

Place the variable count inside the box for which item of arch X to look at.

Then, do the same for arch Y.

Each time the code goes through a loop, the count should go up, so put the change count by one block under the stamp block.

Click on the code to see if this works.

The sprite should go to the first spot, then the second one.

Wait a minute!

The sprite goes to the middle!

In this case, the sprite never even stamped there!

Then it stamped in the first location and missed the second one entirely!

Take a closer look at the count.

It starts at zero, but there is no item zero on your list so the sprite just went to the coordinates (0,0)

or the middle of the screen.

In order to make sure the count is always one the first time the loop runs, place the set count to one block above the loop.

Clear the screen again, now try the code loop again.

This time, the sprite should stamp in the first location, then the second one.

Good job!

Drag the sprite back to the other sprites.

To avoid performing this action every time, place a go to XY block after the loop.

Test the code.

The sprite should return to the starting point after stamping.

Finally, create a button that recreates the picture.

Choose a sprite from the library.

Add a when this sprite is clicked block.

Under it, place a broadcast and wait block.

Broadcast a new message called arch.

Finally, place a when I receive block above the code that recreates the picture.

Do this for each of the sprites.

Each sprite needs its own X and Y list to broadcast messages.

To hide to the lists, click the checkbox next to them in the data menu.

Now it's your turn.

Place the stamp in the correct position using the repeat loop and the length of block, keep track of the times the code has run the loop with a count variable, make the sprite glide to the position of each previous stamp using the glide and item of lists blocks and the count variable.

Choisir une extension
Pivoteur
Faites tourner l'estampille du lutin vers la droite et la gauche quand on appuie sur les touches fléchées.
Chute de blocs (Part 1 of 2)
Créez un jeu dans lequel les utilisateurs construisent un bâtiment à l'aide de blocs qui tombent.
Chute de blocs (Part 2 of 2)
Créez un jeu dans lequel les utilisateurs construisent un bâtiment à l'aide de blocs qui tombent.
Ville Arc-en-ciel
Transformez le paysage en y ajoutant les couleurs de l'arc-en-ciel
Détails
Faites changer les lutins de taille !
Starchitecte
Changez l'arrière-plan à d'autres scènes.
Blueprints (Part 1 of 2)
Blueprints (Part 2 of 2)
arrow_backward Retour
Suivant arrow_forward
Instructions
Regardez la vidéo de présentation pour découvrir les extensions, puis sélectionnes-en une ou plusieurs parmi celles qu’on trouve ci-dessous !