(Redirected from Clones)
Cloning is different from stamping in that stamping only produces a picture of the sprite on the stage, whereas clones are individual sprites that can run scripts and move around. It is different from duplication in that ordinary duplicates are permanent and appear in the sprite pane, whereas clones do not appear in the sprite pane, disappear when the stop sign is pressed, and can be sensed by other sprites using the Touching ()? block with the original sprite as its input.
Uses of Cloning
Cloning should be used whenever a project should have many similar sprites doing similar things. Because clones are made by the project rather than the user, cloning prevents the user from needing to make the same changes to each of many sprites. For example, cloning can be used for:
- Tower Defence games
- Many arcade-style games
- Special effects such as fireworks and snow
- RNG based projects[clarify]
- Mouse trails
- Any project needing many repetitive sprites
|Note:||Click on a block to learn more about it.|
There are three blocks related to cloning, all of which are found in the Control palette:
create clone of [myself v]— clones the sprite selected
when I start as a clone— when a sprite is cloned, this hat block runs in the newly made clone
delete this clone— deletes the clone it runs in and stops all of its scripts
A clone may use Create Clone of () to recursively clone itself.
If a variable is marked "for this sprite only", each clone of the sprite it belongs to will have its own variable with the given name, just as each clone has its own position, direction, pen, etc. This can be used to make clones behave differently from each other.
Cloning in Scratch Mods
In Panther-style cloning, a clone is a copy of a sprite, but it does not appear in the sprite pane, changes made to the original do not affect the clone, and it is deleted when the stop sign is pressed. Much of the code for cloning used in Panther was already present in Scratch 1.4. Scratch 2.0 and onward use this style of cloning.
In Snap!-style cloning, each clone appears in the sprite pane, and may have scripts all of its own. Clones are created with the block
(clone :: operators), which clones a sprite and reports the new clone; sprites are first class in BYOB. (The other important differences between cloning in Scratch and cloning in BYOB are that a clone in BYOB is not merely a copy of the original sprite but can share attributes, and that one can use the () of () to ask a sprite (whether it is a clone or not) for the value of a particular attribute. Snap!, the successor of BYOB 3, offers both temporary and permanent clones.)