Switching Between Screens
Описание | Как переключаться между различными сценами в Scratch. Скрипт проверяет, совпадает ли переменная экрана с экраном для отображения спрайтов. Если да, то спрайты будут отображаться и делать все, что от них требуется. Если нет, то спрайт останется скрытым и не запустит блоки для того времени, когда он будет открыт. |
---|---|
Область знаний | Информатика, Управление, Game design |
Область использования (ISTE) | |
Возрастная категория | 8
|
Поясняющее видео | |
Близкие рецепту понятия | ветвление |
Среды и средства для приготовления рецепта: | Scratch, Snap! |
This article provides a method for switching between screens.
Variables
First, create a variable called screen:
This variable will store which backdrop is shown.
Scripts
Then, in every sprite that would transition, put this:
In short, the script checks whether the screen variable is the same as the screen for showing the sprites. If so, the sprites will show and do whatever is required. If not, it will stay hidden and run the blocks for when it is hidden.
Stage Transitioning
For the stage, put this:
This script constantly switches the backdrop to the string stored in the variable .
Music Transitioning
If music should change based on the screen, add the following script to the Stage (or the sprite playing the music if a sprite is playing the music):
Execute this broadcast every time the music needs to be changed.
Black Screen
To make a black screen, first create a variable called . Then, insert this into the black screen sprite:
Use this to execute the black screen: