FANDOM


The Go Back ( ) Layers block is used to move sprites forward or backwards the number of specified layers. Scratch has no concept of absolute layering or z-index positioning. Instead, to sort the z-order of sprites it is necessary to combine this block with the go to front block.
Go back () layers

Go back () layers block

Sorting in Z-SpaceEdit

Scratch lacks the ability to send a sprite to a certain layer. However, it is possible to accomplish something similar by sending sprites to the front and then backwards a specified number of layers based on their index in a list like so:

//This script fragment will broadcast the sorting messages
forever:
  broadcast [all to front] and wait
  set sprite-index to 0
  broadcast [sort sprites] and wait


//And this fragment will receive the messages and do something with them. In this case, we'll just
//sort sprites based on their y-position, so sprites closer to the bottom of the screen are on top

When I receive [all to front]:
  go to front

When I receive [sort sprites]:
  wait until <sprite-index = my-index>
  go back (y position + 180) layers

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.