Cloning

Lesson

Cloning

If you want multiple versions of the same sprite visible on the screen at once, you can use cloning to do this. A good example of when this is useful is if you have a ship and want it to be able to shoot lasers.

There are 3 blocks that can be used for creating, controlling and deleting clones.

This first block tells the cloned version of the sprite what to do for example telling it to move in a straight line if it was a laser.

This block tells the code to make a new clone of either itself or another sprite in the code. You could tell either the ship or laser to create a clone when an event happens.

This last block tells the clone to delete itself and could be used to remove the laser once it hits another sprite or the edge.

https://scratch.mit.edu//351950512/editor/

Have a go playing with this code and change it so there is a slight time delay for how often you can shoot the lasers and so that the create clone block is within the rocketship sprites code.

Cloning with variables

From the top we know how to clone the bullet by pressing the space key and shooting the robot. Now here is an example of how you can keep cloning of yourself when you touch a sprite each time.

The sprite increases the length each time it touches the apple.

This is the part where we start cloning of ourselves (increase the length) when the length is changed by the statement above. Give it a try and see what’s gonna happen.

@

Not recently active