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.
When there are a lot of sprites in a project, correct layering can become difficult.
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 in conjunction with this value:
- Go to Front — this block sets the layer to the front, "1".
- Go Back () Layers — this block moves the sprite back, raising the layer's value.
- Show Variable () — this block not only shows the variable monitor but also sends it to the front.
- Show List () — 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 Go back (1) layers
That will send it back to layer 2. The Go to front block will send it to layer 1, and the Go back () layers will send it back 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.