In other languages

Help the wiki!

The Scratch Wiki is made by and for Scratchers. Do you want to contribute?

Learn more about joining as an editor!

See discussions in the Community Portal

Backdrop Name (block)

Backdrop name
2.0 Backdrop Name.png
Category Looks
Type Reporter
Introduced in 2.0

The Backdrop name block is a Looks Block and a Reporter Block. The block holds the current backdrop name. This is the first time that the costume/backdrop name can be accessed through a block.

This block can be displayed as a stage monitor.

History

Prior to Scratch 2.0, this block never existed. Instead, the (backdrop #) block had to be used (although it was called "background #" instead). Another alternative would be to list each costume name in a list. Both these blocks are now available and can each be used to meet a specific project's needs. One notable difference is that the (backdrop name) block is available in both the Stage and sprites, while (backdrop #) is only in the Stage.

Example Uses

This block holds the backdrop name of the Stage, therefore it is used when something must happen if the Stage is at a specific backdrop. Some of the more common uses are:

  • Stopping the project once the Stage reaches the backdrop for the end of the project
when gf clicked
wait until <(backdrop name) = [The End]>
stop [all v]
  • Checking what the current backdrop is
if <(backdrop name) = [Level 1]> then
  say [Welcome to the game! Use WASD to move.] for (4) secs
end
if <(backdrop name) = [Level Boss]> then
  say [Watch out for the boss's laser attack!] for (4) secs
end
  • Setting a variable to the current backdrop
set [(variable name) v] to (backdrop name)
This block also gives more meaning to naming backdrops.

Workaround

Main article: List of Block Workarounds

This block can simply be replicated with the following code:

([backdrop name v] of [Stage v])

Sprites

There is currently no dedicated block for accessing a sprite's costume name. However, it can be accessed with the following code:

([costume name v] of [Sprite v])

There is, in fact, the code for the "costume name" block in the source code of Scratch,[1] but it is not normally accessible in the editor.

See Also

References

  1. http://scratch.mit.edu/projects/23639677/
  • This page was last modified on 15 December 2016, at 15:49.