Creating a Multiplayer Game This article or section may not have content matching Scratch Wiki editing standards. Please improve it according to Scratch Wiki:Guidelines and Scratch Wiki:Editing Conventions. Apr 04, 2014 How to create lives in Scratch for a simple Platformer. (These videos are silent to avoid noise in the classroom.).
Home > Middle School > Variables and Expressions in Scratch
|
When experimenting in Scratch on your Raspberry Pi, maybe you want to make the sprite do something like jump when you press one key, hide behind another sprite when you press a different key, or bounce before it hits the edge.
How To Make A Lives Variable On Scratch 1
To do that, you need to know where it is. And you have to be able to change where it is. You can do this in Scratch using variable blocks.
A variable is like a box that holds a number. The box has a name, so you can tell it from other boxes. And it has space for a number.
Variables can remember letters, words, and sentences, too.
Using variables in Scratch
Scratch can do three clever things with variables. The first is make them. Variables have special blocks, and when you make one variable, you get some special blocks to help you use it. You can set the variable to a number or add a number to it.
When you make a variable, it appears on the stage. You don’t always want this, so you can use a hide variable block to make it go away. And you can use a show variable block to make it come back. Realguitar classic.
The second clever thing is math. You can add, subtract, multiply, and divide variables by some number. You can even add, subtract, multiply, and divide one variable by another!
The final clever thing is best of all. You can use a variable wherever you see a number. For example, you can tell a go to block to use a variable you make. When you click the go to block or when Scratch reaches it in a script, the block moves the sprite to the number stored in the variable.
This gives you way more options than moving a sprite to the same place all the time. You can change the numbers by hand. Or with math. Or by making them follow other numbers, like the position of some other sprite.
How To Make A Lives Variable On Scratch 2
Making a variable in Scratch
To make a variable, click the darker orange Variables button at the bottom right of the block types in the block list area. Three buttons appear. You can click them to
How To Make A Variable On Scratch 2
Make a variable
Delete a variable
Make a list
A list is a special kind of a variable that holds other variables. It’s like a big box with lots of smaller boxes inside it. They’re numbered so that you can tell them apart and do things like get the third box and change what’s inside it. You can ignore lists for now.
To make a new variable
Click the make a variable pattern.
You see a window like the one in the following figure.
Mar 19, 2017 Question: Q: How do you recover deleted GarageBand songs on iPad? One of my GarageBand songs got deleted and I'm wondering if there is any way to get it back. I have the most recent version of garage band, and I put it on iCloud but then took it off before it got deleted. https://lednin.netlify.app/how-to-recover-deleted-garageband-projects-on-ipad.html.
Typesprite1_xinto the Variable Name? box.
Leave the For All Sprites option checked and click OK.
Whoa! Stuff happens! Scratch makes some new blocks. And if you look at the stage, you’ll see a box appears, with the name of your variable sprite1_x and a number.
How To Make A Speed Variable On Scratch
When you make a new variable, the number is always 0 because you haven’t changed it yet. The following figure shows what you get.
How To Make A Lives Variable On Scratch Youtube
Can you use variables to replace any number? You totally can! You can use a set block to set a variable to the value of another variable. In a change block, you can make the by value a variable. You can make scripts that are really smart, with variables passing values to other variables between sprites all over the stage. There are almost no limits to what you can do.