Download presentation
Presentation is loading. Please wait.
Published byEleanor Wright Modified over 8 years ago
1
Cloning in Scratch Computer App Session 6
2
Cloning in Scratch Learning Objectives: I will clone sprites in Scratch to create copies of an existing sprite. I will clone sprites in Scratch to create copies of an existing sprite.
3
Cloning in Scratch In Scratch, you can create a copy of any sprite, and it’s called a clone. Clones are used when you want many of the same type of sprite, and they all act the same way.
4
Cloning in Scratch Any sprite can create a clone of itself or another sprite. Any sprite can create a clone of itself or another sprite. You can have a script that runs when the clone is created. You can have a script that runs when the clone is created. You can delete a clone. You can delete a clone.
5
Create a new project Choose a ball for your sprite. Choose a ball for your sprite. From the Events category, drag “when the space key pressed” into the code area. From the Events category, drag “when the space key pressed” into the code area. From the Control From the Control category, drag category, drag “create a clone of “create a clone of myself” underneath myself” underneath it. it.
6
Press the space key. It appears that nothing has happened. Drag the ball from its current position, and you’ll see that you have two of them now. (You didn’t see two at first because when the clone is created, it is exactly the same, including the position) Press the space key. It appears that nothing has happened. Drag the ball from its current position, and you’ll see that you have two of them now. (You didn’t see two at first because when the clone is created, it is exactly the same, including the position) Lets add code to move it when it’s created. Lets add code to move it when it’s created. Click the stop button. Click the stop button.
7
From the Control category, drag “when I start as a clone” into the code area. From the Control category, drag “when I start as a clone” into the code area. From the Motion category, drag “go to x: __ y: __” underneath. From the Motion category, drag “go to x: __ y: __” underneath. Change x to 0 and y to 140 Change x to 0 and y to 140
8
Now, press the space bar and two balls will appear. Now, press the space bar and two balls will appear. Click the stop button again. From the Control category, add “wait 1 sec” and then “delete this clone”. Click the stop button again. From the Control category, add “wait 1 sec” and then “delete this clone”.
9
Your turn: Your new project: – Create a new sprite that will throw the ball – When the space bar is pressed, a ball sprite should be cloned, go to the other sprite, then move 10 in the x direction for 20 times, and then delete itself. (think about what kind of commands you will need) Looks – Use the “hide” and “show” blocks in the Looks category, so that the basketball is hidden to start with, and then is shown when starting as a clone.
10
Your code might look like this
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.