|This article is a stub. It may be incomplete, unfinished, or have missing parts/sections. If the article can be expanded, please do so! There may be suggestions on its talk page. (November 2018)|
In the Scratch Player, sprites are prevented from moving off the edge of the screen; if one tries to make a sprite do so by setting its x or y position to a very large positive or negative number, the sprite will be kept from moving more than around three-fourths of itself off the screen.
However, it is possible to move a sprite completely off the screen by using a trick involving different costumes. There are multiple ways to pull off this trick, one of which is detailed below.
First of all, make two new costumes. Leave one of them blank, and fill the other entirely using the bitmap fill bucket (so that its width is 480 pixels and its height is 360 pixels). If other costumes are needed, create them; they are not subject to any requirements.
Next, create the following script:
when gf clicked ... // if the sprite must do stuff before being moved switch costume to [blank costume v] set size to (10000)% // or some similarly high number switch costume to [completely filled costume v] go to x: (2000) y: (2000) // or whatever position the sprite must be in set size to (100)% // if the sprite's size needs to be reset ... // the rest of the sprite's code after it's moved
A quick rundown on how the above script works:
It first uses a technique that can set a sprite's size to an arbitrarily large number. Basically, an empty costume's size can be set to any number between 100 and 54,000, and changing a sprite's costume does not change its size. This means that, by switching a sprite's costume to the empty costume, setting the size, and then switching back, a sprite can be set to practically any size that is needed.
Next, it exploits the different x and y position limits of different costumes and the fact that a sprite's costume changing will not change its x or y position. A larger costume can move farther off of the screen than a smaller costume, simply because it is larger; this fact can be magnified by using the set size block as shown previously.