From the course: Learning Scratch

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Variables

Variables - Scratch Tutorial

From the course: Learning Scratch

Start my 1-month free trial

Variables

- [Voiceover] Variables allow you to save certain values so that you can recycle those values or keep track of them later on. Think of a variable like a user's score in a game. It's a saved number value that goes up when the user gains points. That's how variables work in code. And that's the basics of how a variable works in Scratch. So let's go over to the Data section and this is where you're going to find the option to create a variable. And you can think of a variable as one of these rounded values that you can put somewhere else. So I'm going to click Make a Variable. And you can make your variable for all sprites or for this sprite only. I'm going to choose for all sprites and I'm going to name this rightEdge. Then I'll click OK. And what this variable is going to represent is the right edge of the screen. So let's say I had other sprites that I was shooting. Imagine the wizard shooting lightning bolts and he's also shooting fireballs or ice cubes or whatever else, and you…

Contents