Sprite Lab Documentation

item
Category:Variables

Gets the value of the specified variable.

Variables are used to store values such as numbers or words. Variables allow for a lot of freedom in programming. Instead of having to type out a phrase many times or remember a number, computer scientists can use variables to reference them. Variable values can change throughout a program. Each time the variable name is used, it gets the current value of the given variable and passes it to the block it is attached to.

Examples

Example 1

This bunny can count by twos! Each time the bunny is clicked, the variable is updated and the new value of the variable is printed.

Example 2

A variable can be used several times in a program. Here, the variable “spriteSize” is used to set all the food sprites to the same size when the apple is clicked.

Syntax

variables_get

Parameters

NameTypeRequired?Description
variable

The name of the variable whose value is being called

Tips

  • If you decide to change a variable name while working on your project, you do not have to change all the other matching the block individually. Choosing to “rename all” variables with that name will automatically rename all the matching blocks used in your project.

Found a bug in the documentation? Let us know at support@code.org.