Time for action - get out of the corner

We need to get the cat out of the corner and moving across the stage in some kind of orderly fashion. We'll do that by replacing the change x by and change y by blocks:

  1. Click on the scissors icon located on the toolbar above the stage to activate the scissors tool.
    Time for action - get out of the corner
  2. Move the scissors over the change x by block until it is outlined in a red square. Click your left mouse button to delete the block.
    Time for action - get out of the corner
  3. Similarly, delete the change y by block.
  4. From the Motion palette, drag the move 10 steps block into your script and snap it in place before the if on edge, bounce block.
  5. From the Looks palette, snap the switch to costume block into place after the move 10 steps block. Double-click the script to set it in motion. Select costume1 from the list of costumes.
  6. Add a second switch to costume block before the move 10 steps block. Select costume2 from the list of costumes.

    Note

    The drop-down menu on the stack of blocks is sensitive. Click directly on the black triangle to display the available selections.

  7. If the cat stopped moving, double-click the script again. It should be running upside down!
    Time for action - get out of the corner
  8. Let's change the rotation of the sprite. Informaton about the current sprite displays directly above the script area. To the left of the sprite are three directional buttons: can rotate, only face left-right, and don't rotate.

    Tip

    Many buttons in Scratch will display a tool tip when you hover your mouse over the button. Try it with the rotation buttons.

    Time for action - get out of the corner
  9. Click on the only face left-right rotation button, and now our sprite doesn't run upside down when it bounces off the side of the stage.

What just happened?

The move 10 steps block made the cat move in the direction it was facing, and when it bounced off the edge of the stage, the cat rotated so that it faced the other way. As the cat rotated, it turned upside down.

When we inserted the switch to costume block and set the value to costume1, the cat appeared to run. What really happened is that at every ten steps, our script displayed a different look as the cat moved across the screen. Our trick was subtle; as we changed the look of the cat, we created the appearance of running.

But we couldn't let the cat run upside down forever, so we adjusted the rotation so that when the cat hit the edge of the stage, it flipped 180 degrees and kept running.

Have a go hero

Make the cat run backward across the screen.

Hint: Set the rotation of the sprite to don't rotate.

Undo an action

If you deleted something you shouldn't have, there is an Undo button at the top of the Scratch window. Clicking Undo attaches the last block you deleted to your cursor, and you're able to snap it in place on the script.

You can only Undo the last action; Scratch doesn't have an unlimited undo capabilities.

Pop quiz

  1. You need to stop your script before you can make changes to it.
    • True
    • False
  2. Why do we use a forever block?
    • It adds a permanent block to the script
    • It means the script can't be changed
    • To execute a set of commands in a continual loop
    • To execute a set of commands while a certain condition exists
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.219.213.196