Skip to content

Please update your browser

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

4. Cacher l'objet

Transcript

In this video, you’ll program the object that the player is looking for to appear in only one location. To start, choose what your sprite is looking for. Click the object sprite, then go to the “costumes” tab. There are a few different choices available. Choose one of these items, or add a different object from the costume library. What might your character need to find?

Once you’ve chosen an object, go back to the “scripts” tab, click “looks,” and drag out “show” and “hide” blocks. The “show” block should run when the backdrop changes. Click events, and drag out a “When backdrop switches” block. Click the dropdown, and select the name of the location where your object will appear. This example uses the cave, but you will choose your own location for the object in your game. Then, drag another “when backdrop switches” block onto the “hide” block, and select “town.”

Click the flag to try it out. Move the sprite to the location you just selected, and great, the sprite appears! Next, program a winning condition that will happen *if* the player sprite touches the object.

Place a forever loop and an “if” statement under the “show” block.

Add a “touching” block from sensing, and select “character” from the dropdown.

Create a winning celebration. You might play a sound, or use a “say” block to say, “Yay, you win!” Click the flag to try it out. Move the sprite until it finds the object, and… great! Now, it’s your turn: Select the object sprite and a costume from the costumes tab.

Show the object in one location using “when backdrop switches” and “show” blocks.

Hide the object at the start of the program using “when backdrop switches” and “hide” blocks. Program a winning condition using “touching,” “forever,” and “if” blocks.

In the next video, you’ll add more storytelling elements to make your game more exciting.

arrow_backward Retour
Suivant arrow_forward
Instructions
  1. Programme le jeu pour qu'il commence sur l'arrière-plan "Ville".
  2. Pour chaque lutin Entrée :
  • programme le changement d'arrière-plan
  • Cache tous les lutins Entrée lorsque l'arrière-plan change.
  • Montre tous les lutins Entrée lorsque l'arrière-plan bascule sur "Ville".