Skip to content

Please update your browser

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


In this add-on, you’ll add objects to your game that make different sounds as the sprite walks over them. You can even arrange the objects in different ways so the user can play a song. Adding unique features for players to discover keeps them engaged and makes your game more enjoyable. To start, click the flag, and move the sprite into the location you want to add the objects. This example uses the cave.

Then, add a new sprite. Choose one from the library, or paint your own. This example will use a small, red square. Go to the scripts tab of the new sprite. Open the “sounds” menu, and drag out a “play note” block. Click on it to hear what it sounds like. Cool! It plays the “C” note. If you don’t like this note, choose another one from the dropdown menu. To change what the note sounds like, add a “set instrument” block above the “play note” block, and select the instrument you want to use from the dropdown menu. Click the block stack to hear what the instruments sound like. Choose one that’s appropriate for the setting. This example uses the vibraphone.

To make the object play this note when the sprite walks over it, put an “if” block around the two sound blocks. Then, place a “touching” block inside the condition slot, and select the character sprite from the dropdown menu. Add a “forever” block around the “if” block, so the sprite checks the condition continuously.

Test the code by clicking the stack, then using the movement keys to make the sprite walk over the object. Cool! The sound plays! If the object is on top of the sprite, fix it by dragging the character sprite. If the notes are playing too fast, change their duration using the “beats” bubble inside the “play note” block.

Click the flag to test the program. Oh no! The object appears in town, but it should only appear in the cave. Fix this by adding two “when backdrop switches” blocks from the “events” menu. Change the dropdown in one to “town,” and change the other to the location where you placed your objects. Then, open the “looks” menu, and add a “hide” block under “town” and a “show” block under the location you selected. Snap the forever loop underneath the “show” block.

Test the code again by clicking the flag. Great! The object no longer appears in town.

When the sprite enters the cave, the object appears, and it makes sounds when the sprite walks over it. Explore adding more musical objects so the user can play a song.

Duplicate the object by right clicking on it and selecting “duplicate.” In the new sprite, change its appearance, and the note it plays. Drag it to where you want it to appear. Do this as many times as you would like. This example adds many new sprites Now, it’s your turn! Add a new sprite.

Add an instrument and note combination using “set instrument” and “play note” blocks.

Make the sound play as the sprite walks over the object using “touching,” “if,” and “forever” blocks. Make the object show only in a specific location using the “when backdrop switches,” “show,” and “hide” blocks.

Duplicate the sprite, and change its appearance and sound as many times as you like.

Scegli un’estensione
Risistema gli accessori
Personalizza l'aspetto di ciascun luogo.
Rendi il gioco più impegnativo mostrando l'oggetto solo se il personaggio si trova nelle vicinanze.
Codifica una conclusione
Aggiungi alcune slide per concludere la storia quando il giocatore vince.
Oggetti musicali
Aggiungi elementi interattivi che emettono un suono quando il personaggio ci cammina sopra.
Ostacoli ostruenti
Rendi le mappe più realistiche, impedendo al personaggio di imbattersi in ostacoli come alberi o edifici.
Nascondi l'oggetto in un luogo casuale ogni volta.
arrow_backward Indietro
Avanti arrow_forward