• Embed Doc
  • Readcast
  • Collections
  • CommentGo Back
Download
 
Meet Thirsty: String Operator inScratch
In this post, we will learn to use the string and the list features in Scratch. In thespirit of Shall We Learn, I will show you in a project. This project is called
I AmThirsty
. We will create a stick figure sprite as our main sprite; we will also a drinksprite. You can help this poor thirsty guy by moving the drink sprite to him with yourmouse. Then we will create many drink sprite based on the first drink sprite.First, create a new project and create a new sprite. If you don’t know how to do this,I recommend reading at least the first four lessons of Scratch Programmingavailable on this site.Name this sprite
Thirsty 
. Here is mine. To demonstrate how to use the new
string
features in Scratch, let’s create avariable to hold the result string of adding all the names of the drinks he hasconsumed.Click the orange Variables button at the left panel and click
Make a variable
button. Enter “drink list” as the list name and keep this list visible for all sprites. Then click OK.
 
Create a broadcast message called “consumed”. This broadcast message will besent by the drink sprites later.Create scripts as shown below.
Thirsty
sprite sets
drink list
variable to an emptystring when the game starts, then it waits for the
consumed
broadcast message.Each time a consumed broadcast message is received, it says what’s in
drink list
variable for 2 seconds.Let’s move on to the drink sprite. Create a sprite or get one from Scratch library,and rename it to “tea”.
 
Select
tea
sprite’s Scripts tab, and create a
local variable
named “name”.Create the scripts as shown below. Note that you need to add a empty space beforethe “tea” so the result concatenated string looks right.
of 00

Leave a Comment

You must be to leave a comment.
Submit
Characters: ...
You must be to leave a comment.
Submit
Characters: ...