SCRATCH TUTORIAL SPACE SHUTTLE MISSION STS-2020
Lesson 6 Create Script to Rotate the Shuttle sprite
- Description.
This script will use the mouse to rotate the Shuttle.
If you haven't already, Launch the Scratch program from your desktop. - Let's get started!!!
- We will be using the freedom background. Click on the Stage icon, Select the freedombg.
Click on the tab
- Script to rotate the Shuttle.
Grab this block and drag it into the script area.
Click on the arrow and then click on mouse pointer to select the mouse pointer.
Doubleclick on the block to test.
The Shuttle should turn towards the mouse.
Doubleclick on the green flag contol block to move the Shuttle back to the starting position.
We only want the Shuttle to point towards the mouse when we hold down the mouse button
Let's make a conditional statement for the Shuttle.
If the mouse down, point towards the mouse
Let's make the Script
Click on
Grab this block and drag it into the script area.
Click on
Grab this block and drag it into the script area.
Snap the blocks together.
Doubleclick to test.
The Shuttle pointed toward the mouse but it was so fast.
When need the Shuttle to point towards the mouse as long as we hold the button down.
We could use the forever if block.
Then the Shuttle would point to the mouse everytime you clicked the button.
Not good, it would rotate when you didn't want it to.
Let, use the a key to control when the Shuttle rotates.
Let's make a new conditional statement for the Shuttle.
When the a key is pressed, if the mouse down, point towards the mouse
Click on
Grab this block and drag it into the script area.
Snap it on to the block.
Click on the arrow and select the a key.
Test it. Press and hold down the a key. Hold down the mouse button, now move the mouse in a circle. The Shuttle follows the mouse.
- Set rotation Center.
Click on then click on the Edit button.
Click on the button Set Rotation Center. Click on the Shuttle to move the crosshairs.
Move the crosshairs to the middle of the Shuttle then click OK
Test it. The Shuttle should rotate around it's center when you move the mouse in a circle.
Try setting the Rotation Center different places on the Shuttle and see what happens.
Let's add the Shuttle direction indicator to the stage.
Click on the button
In the Script block area find the direction block.
Click inside the box to check it.
- Let's update our Notes.
Add, Press and hold down the a key. Hold down the mouse button and move the mouse to Rotate the Shuttle.
Click OK