(Redirected from Switch to Background () (block))
Switch Backdrop to () | |
switch backdrop to ( v) | |
Category | Looks |
Type | Stack |
Introduced in | 06Oct06 (0.x) |
The Switch Backdrop to () block is a Looks block and a stack block. The block changes the stage's backdrop to the specified one.
This block is a commonly used block; it is used whenever the stage must switch to a specific backdrop (instead of the Next Backdrop block, which does not always give the same backdrop). A variable (or any reporter) containing a number or the name of a backdrop can be dropped in.
A sprite's version is Switch Costume to ().
History
set scenery to [scene1 v]:: looks
In early versions of Scratch, the Stage did not have its own dedicated "Switch Backdrop to ()" block, and instead made use of the Switch Costume to () block (known as "Set Costume to ()" at the time) to switch between backdrops. The first noteworthy version is 03Oct06, replacing the Set Costume to () block with a "Set Scenery to ()" block. The block was made an obsolete block one version later in 06Oct06, being replaced with a "Set Background to () block". The block was later renamed to "Switch to Background ()", and was left unaltered for every subsequent 1.x version.
In early 2.0 prealpha, the block was called "Show Background ()", but the name change was reverted sometime in late 2010/early 2011. From the transition from 2.0 prealpha to 2.0 alpha, the Switch to Background () block was made into a hidden block. In its place was a "Start Scene ()" block (not to be confused with the Start Scene () (Events block) block), which was accessible to sprites in addition to the Stage. The Start Scene () was renamed multiple times throughout 2.0 alpha; the block was first renamed to "Switch Scene to ()" sometime around v121, to "Switch to Scene ()" sometime around v132, before finally landing on the name "Switch Background to ()" in v172. The "next backdrop" and "previous backdrop" options were also added in v172, and in v194, the previously hidden "Switch to Background ()" block was merged with the "Switch Background to ()".
In Scratch 3.0, the "random backdrop" option was added to the block.
Set Attributes
Aside from the attributes of all the backdrops, the three options "previous backdrop", "next backdrop", and "random backdrop" are available in the drop-down menu.
Example Uses
Because of its simplicity, this block does not have a specific list of main uses; it is simply used to change the background of the stage. It can be used in animations, games, simulations—anything that requires changes between backgrounds.
Some common uses are as follows:
- Starting a level
switch backdrop to (level1 v)
when backdrop switches to [level1 v]//in a sprite go to x: (0) y: (0)
- A game over message
switch backdrop to (game over v)
when backdrop switches to [game over v] hide
- Simply changing backdrops
switch backdrop to (backdrop2 v)
Workaround
- Main article: List of Block Workarounds
This block can be replicated with the following code:
repeat until <(wanted backdrop #) = (backdrop [number v])> next backdrop end
However, it is often much faster to use the original block.
It can also be replicated with a sprite that stamps the new background.
See Also
For sprites |
Say () for () Seconds • Say () • Think () for () Seconds • Think () • Switch Costume to () • Next Costume • Switch Backdrop to () • Next Backdrop • Change Size by () • Set Size to ()% • Change () Effect by () • Set () Effect to () • Clear Graphic Effects • Show • Hide • Go to () Layer • Go () () Layers • Costume () • Backdrop () • Size
|
For the Stage |