Skip to content

Please update your browser

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

3. Réapparaître sur scène

Transcript

In this video, you'll learn how to use the "go to" block and the "forever” loop to make the sprite move continuously across the stage.

Right now, when you click the block stack, the sprite glides to the center of the stage and to the right. You want the sprite to look like it walks off the stage, then walks back onto it from the left. To do this, use the "go to" block from the motion menu. This block makes the sprite instantly appear anywhere on stage. Drag the sprite to the left of the stage, where you want it to appear. This will automatically update the x and y values in the "go to" block. Drag and snap the "go to" block onto the top of the block stack, then click it to see what happens. The sprite appears on the left of the screen, glides to the center of the stage, then glides to the right. Clicking the block stack multiple times makes the sprite seem to move off the right side of the stage, then reappear on the left side.

The “go to” and the “glide” block both have x and y values. The “go to” block is the simplest way to move a sprite to another spot without displaying any animation; the sprite just appears! It’s used whenever a sprite needs to jump from one spot to another.

The “glide” block, on the other hand, makes the sprite visibly move across the screen at a speed determined by you. Right now your sprite glides across the stage.

To make this happen repeatedly, use a loop! A loop repeats a set of computer instructions over and over for a specified number of times, or forever.

A “forever” block is a type of loop that repeats the entire time the program is run.

Click on the control menu, and drag a “forever” block into your code stack so that it snaps around your other code blocks. Now, when you click on the block stack, the code blocks inside the forever loop will continuously run, until you click the stop sign to stop your program. Now, it's your turn: Go to your Scratch browser tab. Drag the sprite to a starting position on the stage. From the motion menu, drag the “go to” block to the top of the code stack From the control menu, select the “forever” block, and snap it around your block stack.

After getting your model to continuously walk across the stage, return to this screen and click the green Next arrow to move on to the next video.

arrow_backward Retour
Suivant arrow_forward
Instructions
  1. Fais en sorte que le lutin réapparaisse sur le côté gauche de la scène.
  2. Fais en sorte que le lutin se déplace sans cesse et réapparaisse dans la scène.