A morph's layer is the justification of sprites or Stage Monitors being shown in front or behind each other. A lower layer value is shown in front, or closer to the viewer, so a layer of "1" appears at the front. When an object is created, it appears at the front, as well as when it is dragged in the project editor.
A monitor's layer changes depending on when it shows. When a stage monitor shows, it immediately is sent to the front layer, but other sprites and monitors can overlap it if they are sent to the front layer. There is not currently a way to directly send a monitor's layer back or forward a specific value without adjusting the layer values of the other sprites.
The following blocks can be used to affect this value:
go to [front v]— this block sets the layer to the front or back layer.
go [backwards v] () layers— this block moves the sprite backwards or forwards, allowing the sprite to fine-tune its layer value.
show variable [ v]— this block not only shows the variable monitor but also sends it to the front.
show list [ v]— this block not only shows the list monitor but also sends it to the front.
There are currently no blocks to set the layer directly, nor to report it.
Viewing the Specific Layer Value
Though not available through the Scratch user interface, the specific value of a sprite's layer can be seen through a short process.
- In the project editor, select File > Download to your computer
- At the end of the project file name, type in
.zipto archive it into a zipped folder
- After saving the zipped project, extract the files
- Open up the JSON file near the bottom of the folder in any text editor (i.e. Notepad++)
- Within the arranged codes are the layer values for each object, or sprite. The value can be changed directly within the text editor and saved before compressing the zipped file again.
Sending a Sprite to a Specific Layer
Even though there is no block available to send a sprite to a specific layer, there is a process that can accomplish this task.
go to [front v] go [backward v] (1) layers
This will send it to layer 2. The
go to [front v] block sends it to layer 1, and the
go [backward v] (1) layers block will send it forward/backward as many layers as needed.
As this value tells sprites where to go, it has many uses. Some example uses:
- Layering objects and sprites in a scene.
- Creating 3D scenes.
- Displaying the terrain of a scrolling project in the background.
- Displaying menu items in front of the menu.
- Displaying the score or other variable monitor in front of the project-play.