Cloning – Scratch Wiki

Cloning is a feature that allows a sprite to create a copy of itself while the project is running. Each clone has the same costumes, sounds, scripts, and variables as the original but is otherwise independent.

Cloning is different from stamping in that stamping only produces an image of the sprite on the stage, whereas clones are individual sprites that are able to interpret scripts and run seperately. Stamping will also by default stamp a bitmap image of the sprite. It is also different from the "duplicate" option in the sprite menu 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.

There may only be 300 clones at once to prevent excessive lagging or crashes,[1] but 301 could be made in Scratch 2.0.[2]

Cloning is commonly used when a project has many similar sprites doing similar things. Because clones are created by the project rather than the user, cloning prevents the user from needing to make the same changes to each of many sprites. Some common uses of cloning include:

There are three blocks related to cloning, all of which are found in the control palette:

Clones can also create clones, which is often used for recursion.

If a variable is marked as "for this sprite only", each clone of the sprite will have its own value for the variable that is separate from the original sprite and all other clones. This can be used to store information for individual clones, such as health for enemies in some Game Projects.

There are two different types of cloning implemented in different Scratch modifications. They are commonly referred to as "Panther-style cloning" and "BYOB-style cloning".[citation needed]

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 uses this style of cloning.

In BYOB-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.)

Cookies help us deliver our services. By using our services, you agree to our use of cookies.

See the rest here:

Cloning - Scratch Wiki

Related Posts

Comments are closed.