Music and Drawing

Music

How do I play an instrument?

Check out all of the sound code blocks to see different instruments you can use. For example, you can use the {"func":"blockSoundPlayDrum"} or the {"func":"blockSoundSetInstrument"} blocks.

Sample Code:
{"func":"registerFlagTrigger","values":[],"containers":[],"next":{"func":"blockSoundPlayDrum","values":[{"type":"choice","value":"37 Side Stick"},{"type":"number","value":"5"}],"containers":[],"next":{"func":"blockSoundSetInstrument","values":[{"type":"choice","value":"3 Electric Grand Piano"}],"containers":[],"next":{"func":"blockSoundPlayNote","values":[{"type":"number","value":"60"},{"type":"number","value":"0.5"}],"containers":[],"next":{"func":"blockSoundPlayNote","values":[{"type":"number","value":"65"},{"type":"number","value":"0.5"}],"containers":[],"next":{"func":"blockSoundPlayNote","values":[{"type":"number","value":"70"},{"type":"number","value":"0.5"}],"containers":[]}}}}}} Add to my Backpack

Sample Projects:    Music maker


How do I add a soundtrack to my project?

Click on the Sounds tab in one of your Actor’s code. Then click on Add Sound to browse the Media Library.


How can you play a music file when you click an Actor?

Attach the {"func":"blockSoundPlay"} below the {"func":"registerSpriteTrigger"} block and select a sound. If there are no options to choose from, go add some sounds in the sounds tab!

Sample Code:
{"func":"registerSpriteTrigger","values":[],"containers":[],"next":{"func":"blockSoundPlay","values":[{"type":"string","value":"bounce"}],"containers":[]}} Add to my Backpack

Sample Projects:    Rock Band, Evil Alien Planet


How can you keep playing a music file continuously?

Add a {"func":"blockSoundPlayUntilDone"} block in the Stage’s code under the {"func":"registerFlagTrigger"} block. If you want it to play forever, put it inside a forever loop.

Sample Code:
{"func":"registerFlagTrigger","values":[],"containers":[],"next":{"func":"blockControlForever","values":[],"containers":[{"func":"blockSoundPlayUntilDone","values":[{"type":"string","value":"Bedtime"}],"containers":[]}]}} Add to my Backpack

Sample Projects:    Background Music, Four Seasons


{"func":"blockSoundPlayDrum"}

Play Drum

"Play Drum" plays the specified kind of drum for the specified number of beats.

Parameters:

Drum type: this parameter is the type of drum you want to play. There are many options to choose from.

NumBeats: this parameter is the number of beats you want the drum to play for.

Related Blocks:
{"func":"blockSoundRest"} ,     {"func":"blockSoundPlayNote"} ,     {"func":"blockSoundSetInstrument"}

Sample Code:
{"func":"registerSpriteTrigger","next":{"func":"blockSoundSetVolume","values":[{"type":"number","value":"100"}],"next":{"func":"blockSoundSetTempo","values":[{"type":"number","value":"60"}],"next":{"func":"blockSoundPlayDrum","values":[{"type":"choice","value":"35 Acoustic Bass Drum"},{"type":"number","value":"0.2"}]}}}} Add to my Backpack


{"func":"blockSoundRest"}

Rest For Beats

"Rest For Beats" stops playing for the specified number of beats.

Parameters:

NumBeats: this parameter is the number of beats you want the drum to rest for.

Related Blocks:
{"func":"blockSoundPlayDrum"} ,     {"func":"blockSoundPlayNote"} ,     {"func":"blockSoundSetInstrument"}

Sample Code:
{"func":"blockSoundChangeTempo","values":[{"type":"number","value":"20"}],"next":{"func":"blockSoundRest","values":[{"type":"number","value":"0.2"}],"next":{"func":"blockSoundSetInstrument","values":[{"type":"choice","value":"1 Acoustic Grand Piano"}],"next":{"func":"blockSoundPlayNote","values":[{"type":"number","value":"60"},{"type":"number","value":"10"}]}}}} Add to my Backpack


{"func":"blockSoundPlayNote"}

Play Note

"Play Note" plays the specified note for the specified number of beats.

Parameters:

Note: this parameter is a note, indicated by a number. The higher the number, the higher the note.

NumBeats: this parameter is the number of beats you want to note to play.

Related Blocks:
{"func":"blockSoundPlayDrum"} ,     {"func":"blockSoundRest"} ,     {"func":"blockSoundSetInstrument"}

Sample Code:
{"func":"blockSoundChangeTempo","values":[{"type":"number","value":"20"}],"next":{"func":"blockSoundRest","values":[{"type":"number","value":"0.2"}],"next":{"func":"blockSoundSetInstrument","values":[{"type":"choice","value":"1 Acoustic Grand Piano"}],"next":{"func":"blockSoundPlayNote","values":[{"type":"number","value":"60"},{"type":"number","value":"10"}]}}}} Add to my Backpack


{"func":"blockSoundSetInstrument"}

Set Instrument

"Set Instrument" sets the current instrument to the instrument specified by the parameter.

Parameters:

Instrument: you have many instrument options to choose from for this parameter, including "Acoustic Grand Piano," "Xylophone," "Percussive Organ," and more.

Related Blocks:
{"func":"blockSoundPlayDrum"} ,     {"func":"blockSoundRest"} ,     {"func":"blockSoundPlayNote"}

Sample Code:
{"func":"blockSoundChangeTempo","values":[{"type":"number","value":"20"}],"next":{"func":"blockSoundRest","values":[{"type":"number","value":"0.2"}],"next":{"func":"blockSoundSetInstrument","values":[{"type":"choice","value":"1 Acoustic Grand Piano"}],"next":{"func":"blockSoundPlayNote","values":[{"type":"number","value":"60"},{"type":"number","value":"10"}]}}}} Add to my Backpack


{"func":"blockSoundChangeTempo"}

Change Tempo

"Change Tempo" changes the project’s tempo to the specified number of beats per minute.

Parameters:

Tempo Change: the tempo will increase by this number. Use a negative number to make the tempo slower.

Related Blocks:
{"func":"blockSoundSetTempo"} ,     {"func":"valueSoundTempo"}

Sample Code:
{"func":"blockSoundChangeTempo","values":[{"type":"number","value":"20"}],"next":{"func":"blockSoundRest","values":[{"type":"number","value":"0.2"}],"next":{"func":"blockSoundSetInstrument","values":[{"type":"choice","value":"1 Acoustic Grand Piano"}],"next":{"func":"blockSoundPlayNote","values":[{"type":"number","value":"60"},{"type":"number","value":"10"}]}}}} Add to my Backpack


{"func":"blockSoundSetTempo"}

Set Tempo

"Set Tempo" sets the project’s tempo to the specified number of beats per minute.

Parameters:

BPM: the tempo will be set to this parameter, a number that indicates how many beats per minute your instruments should play.

Related Blocks:
{"func":"blockSoundChangeTempo"} ,     {"func":"valueSoundTempo"}

Sample Code:
{"func":"registerSpriteTrigger","next":{"func":"blockSoundSetVolume","values":[{"type":"number","value":"100"}],"next":{"func":"blockSoundSetTempo","values":[{"type":"number","value":"60"}],"next":{"func":"blockSoundPlayDrum","values":[{"type":"choice","value":"35 Acoustic Bass Drum"},{"type":"number","value":"0.2"}]}}}} Add to my Backpack


{"func":"valueSoundTempo"}

Tempo

"Tempo" returns the current project"s tempo.

Parameters:

None.

Related Blocks:
{"func":"blockSoundChangeTempo"} ,     {"func":"blockSoundSetTempo"}

Sample Code:
{"func":"blockControlForever","containers":[{"func":"blockSoundChangeTempo","values":[{"type":"number","value":"20"}],"next":{"func":"blockControlIf","values":[{"type":"wrapper","func":"valueOpGreater","values":[{"type":"wrapper","func":"valueSoundTempo"},{"type":"string","value":"60"}]}],"containers":[{"func":"blockSoundSetTempo","values":[{"type":"number","value":"10"}]}]}}]} Add to my Backpack


{"func":"blockSoundPlayUntilDone"}

Play Sound Until Done

"Play Sound Until Done" plays the specified sound and waits until it is finished before continuing the script.

Parameters:

Soundtrack: this parameter should be one of the sounds you have added to the project under the "sounds" tab.

Related Blocks:
{"func":"blockSoundPlay"} ,     {"func":"blockSoundStopAll"}

Sample Code:
{"func":"registerSpriteTrigger","next":{"func":"blockSoundPlayUntilDone","values":[{"type":"string","value":"female laugh"}]}} Add to my Backpack


{"func":"blockSoundPlay"}

Play Sound

"Play Sound" block plays the specified sound while the current script is executing.

Parameters:

Soundtrack: this parameter should be one of the sounds you have added to the project under the "sounds" tab.

Related Blocks:
{"func":"blockSoundPlayUntilDone"} ,     {"func":"blockSoundStopAll"}

Sample Code:
{"func":"registerBackgroundChange","values":[{"type":"string","value":"Game Over"}],"next":{"func":"blockSoundPlay","values":[{"type":"string","value":"gamesound8"}]}} Add to my Backpack


{"func":"blockSoundChangeVolume"}

Change Volume

"Change Volume" increments the volume by the number specified.

Parameters:

Volume Change: "Change Volume" will increment the volume by the number specified by this parameter. Use a negative number to make the volume lower.

Related Blocks:
{"func":"blockSoundSetVolume"} ,     {"func":"valueSoundVolume"}

Sample Code:
{"func":"registerFlagTrigger","next":{"func":"blockControlRepeatUntil","values":[{"type":"wrapper","func":"valueOpNot","values":[{"type":"wrapper","func":"valueVar","name":"Playing"}]}],"containers":[{"func":"blockSoundChangeVolume","values":[{"type":"number","value":"1"}]}]}} Add to my Backpack


{"func":"blockSoundSetVolume"}

Set Volume

"Set Volume" sets the volume as the specified percentage.

Parameters:

Percentage: this parameter is the percentage by which the volume will increase. Use a number below 100 to decrease the volume.

Related Blocks:
{"func":"blockSoundChangeVolume"} ,     {"func":"valueSoundVolume"}

Sample Code:
{"func":"registerSpriteTrigger","next":{"func":"blockSoundSetVolume","values":[{"type":"number","value":"100"}],"next":{"func":"blockSoundSetTempo","values":[{"type":"number","value":"60"}],"next":{"func":"blockSoundPlayDrum","values":[{"type":"choice","value":"35 Acoustic Bass Drum"},{"type":"number","value":"0.2"}]}}}} Add to my Backpack


{"func":"valueSoundVolume"}

Volume

"Volume" returns the project’s current volume.

Parameters:

None.

Related Blocks:
{"func":"blockSoundChangeVolume"} ,     {"func":"blockSoundSetVolume"}

Sample Code:
{"func":"blockControlIf","values":[{"type":"wrapper","func":"valueOpGreater","values":[{"type":"wrapper","func":"valueSoundVolume"},{"type":"string","value":"100"}]}],"containers":[{"func":"blockSoundSetVolume","values":[{"type":"number","value":"0"}]}]} Add to my Backpack


Drawing

Draw with an Actor?

You can use an Actor to lead the pen around the Stage by having the pen draw the Actor’s path. Just use the {"func":"blockPenDown"} block in the Actor’s code and control the Actor with movement code.

Sample Code:
{"func":"registerFlagTrigger","values":[],"containers":[],"next":{"func":"blockPenDown","values":[],"containers":[],"next":{"func":"blockPenClear","values":[],"containers":[],"next":{"func":"blockControlWait","values":[{"type":"number","value":"1"}],"containers":[],"next":{"func":"blockPenDrawRectangle","values":[{"type":"number","value":"10"},{"type":"number","value":"10"},{"type":"number","value":"10"},{"type":"number","value":"25"}],"containers":[],"next":{"func":"blockControlWait","values":[{"type":"number","value":"1"}],"containers":[],"next":{"func":"blockPenDrawTriangle","values":[{"type":"number","value":"-50"},{"type":"number","value":"-50"},{"type":"number","value":"-45"},{"type":"number","value":"-45"},{"type":"number","value":"-50"},{"type":"number","value":"-45"}],"containers":[],"next":{"func":"blockControlWait","values":[{"type":"number","value":"1"}],"containers":[],"next":{"func":"blockPenDrawEllipse","values":[{"type":"number","value":"50"},{"type":"number","value":"50"},{"type":"number","value":"10"},{"type":"number","value":"10"}],"containers":[]}}}}}}}}} Add to my Backpack

Sample Projects:    Geometric Shapes, Flower Art


How do I change something’s color?

If you want to change an Actor’s color, you should add a Costume and change the Costume. However, if you want to change the pen’s color, remember that colors are represented by numbers in programming. Choose an initial color on the visual spectrum and then add or subtract from that number with the {"func":"blockPenChangeHue"} code block.

Sample Code:
{"func":"registerFlagTrigger","values":[],"containers":[],"next":{"func":"blockLooksShow","values":[],"containers":[],"next":{"func":"blockPenDown","values":[],"containers":[],"next":{"func":"blockControlForever","values":[],"containers":[{"func":"blockMotionMove","values":[{"type":"number","value":"10"}],"containers":[],"next":{"func":"blockPenChangeHue","values":[{"type":"number","value":"10"}],"containers":[],"next":{"func":"blockMotionBounceOnEdge","values":[],"containers":[]}}}]}}}} Add to my Backpack

Sample Projects:    Flower Art, Simple Painting, Sketch Racer


How do I make the pen thicker?

Use the {"func":"blockPenChangeSize"} block to make the pen appear thicker.

Sample Code:
{"func":"registerFlagTrigger","values":[],"containers":[],"next":{"func":"blockLooksShow","values":[],"containers":[],"next":{"func":"blockPenDown","values":[],"containers":[],"next":{"func":"blockPenChangeSize","values":[{"type":"number","value":"5"}],"containers":[],"next":{"func":"blockControlForever","values":[],"containers":[{"func":"blockMotionMove","values":[{"type":"number","value":"10"}],"containers":[],"next":{"func":"blockMotionBounceOnEdge","values":[],"containers":[]}}]}}}}} Add to my Backpack

Sample Projects:    Flower Art


How do I draw shapes?

The pen section has a lot of code blocks for drawing shapes at a particular x and y value with a certain width/height.

Sample Code:
{"func":"registerFlagTrigger","values":[],"containers":[],"next":{"func":"blockPenDown","values":[],"containers":[],"next":{"func":"blockPenClear","values":[],"containers":[],"next":{"func":"blockControlWait","values":[{"type":"number","value":"1"}],"containers":[],"next":{"func":"blockPenDrawRectangle","values":[{"type":"number","value":"10"},{"type":"number","value":"10"},{"type":"number","value":"10"},{"type":"number","value":"25"}],"containers":[],"next":{"func":"blockControlWait","values":[{"type":"number","value":"1"}],"containers":[],"next":{"func":"blockPenDrawTriangle","values":[{"type":"number","value":"-50"},{"type":"number","value":"-50"},{"type":"number","value":"-45"},{"type":"number","value":"-45"},{"type":"number","value":"-50"},{"type":"number","value":"-45"}],"containers":[],"next":{"func":"blockControlWait","values":[{"type":"number","value":"1"}],"containers":[],"next":{"func":"blockPenDrawEllipse","values":[{"type":"number","value":"50"},{"type":"number","value":"50"},{"type":"number","value":"10"},{"type":"number","value":"10"}],"containers":[]}}}}}}}}} Add to my Backpack

Sample Projects:    Flower Art, Drawing Shapes, Spiral


How do I stop drawing?

The {"func":"blockPenUp"} block will stop the pen from drawing.

Sample Code:
{"func":"registerKeyTrigger","values":[{"type":"choice","value":"space"}],"containers":[],"next":{"func":"blockPenUp","values":[],"containers":[]}} Add to my Backpack

Sample Projects:    Simple Painting, Pom Pom


What kinds of visual effects can I apply?

The {"func":"blockLooksChangeEffect"} block has a bunch of effects for you to use. For example, you can use ghost, brightness, color, fisheye, whirl, pixelate, and mosaic effects.

Sample Code:
{"func":"registerFlagTrigger","values":[],"containers":[],"next":{"func":"blockLooksSetEffect","values":[{"type":"choice","value":"pixelate"},{"type":"number","value":"10"}],"containers":[]}} Add to my Backpack

Sample Projects:    Ghost UFO


How do I print words on the Stage?

Writing text can involve a lot of code blocks. You can use the {"func":"blockPenDrawText"} code block and specify a location to draw the text. Sometimes, you’ll have two strings of text, in which case you need to join them with the {"func":"valueOpJoin"} block.

Sample Code:
{"func":"registerFlagTrigger","values":[],"containers":[],"next":{"func":"blockPenClear","values":[],"containers":[],"next":{"func":"blockPenSetFont","values":[{"type":"choice","value":"normal"},{"type":"choice","value":"24"},{"type":"choice","value":"Arial,Helvetica,sans-serif"}],"containers":[],"next":{"func":"blockPenDrawTextAt","values":[{"type":"wrapper","func":"valueOpJoin","values":[{"type":"string","value":"hello "},{"type":"string","value":"world!"}]},{"type":"number","value":"-50"},{"type":"number","value":"0"}],"containers":[]}}}} Add to my Backpack

Sample Projects:    Using fonts, What’s Your Name?, Asking Questions