From Test-Scratch-Wiki

当背景换成 ()
2.0 When Backdrop Switches to ().png
Category 事件类积木
Type 半圆形积木
Introduced in 2.0

The 当背景换成 () 积木 is an 事件类积木 and a 半圆形积木. 程式 that wear this block will be triggered once the specified 背景 has been switched to on the 舞台.


  • Starting a level
背景換成 [level1 v]
當背景換成 [level1 v] // 在角色上
定位到 x: (0) y: (0)
  • A game over message
背景換成 [game over v] //  在舞台上
當背景換成 [game over v] //  in a sprite
  • Switching among menus
背景換成 [menu 3 v]
當背景換成 [menu 3 v] // 當 "menu 3" 被開啟時
圖層上移至頂層 // 因此 menu 的項目會顯示在最前面
顯示 // 這會開啟 menu


This block can use 递归 to continuously run scripts. An example is as follows:

當背景換成 [snow storm v] // a background switch must first be triggered to begin the recursion
. . .
背景換成 [sunny day v] // which will trigger the next script

當背景換成 [sunny day v]
. . .
背景換成 [snow storm v] // starts the cycle over


When the backdrop changes, sprites with the 当背景换成 () block, and the attribute as the backdrop being changed to (meaning the selected backdrop within the block is what is being switched to), the sprites will react and run their scripts beginning with this hat block. 广播 can be used to replicate this situation, though there may be a miniscule delay due to an extra block being added. The following is a workaround, often used in Scratch 1.x:

背景換成 [valley v]
廣播訊息 [valley v]

當收到訊息 [valley v]
. . .


Cookies help us deliver our services. By using our services, you agree to our use of cookies.