Top Banner
Scratch Responding to Input
13

Scratch

Mar 19, 2016

Download

Documents

Ivi

Scratch. Responding to Input. Lesson Objectives. Look at what the term input means See how to control a sprite using keys See how to move a sprite in small steps Change sprites (or costumes). Movement costumes. Before we start coding we need our costumes! - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Scratch

Scratch

Responding toInput

Page 2: Scratch

Lesson Objectives

● Look at what the term input means● See how to control a sprite using keys● See how to move a sprite in small steps● Change sprites (or costumes)

Page 3: Scratch

Movement costumes

● Before we start coding we need our costumes!

● We need to create a sprite for each direction they will be facing.

● This can be done by rotating the sprite and tweaking.

Page 4: Scratch

Importing costumes

● This can be done on the costumes tab.

● Simply click import and load up the 4 images

Page 5: Scratch

Responding to key press

● Under control is the “when x key pressed”

● Anything connected to this will run when that key is pressed.

● You can choose the key by selecting from the drop down

Page 6: Scratch

Sequence of events

● What are the sequence of events for going left?

● And no it is not just “go left”!

Page 7: Scratch

Sequence of events

● Change costume to “left”● Move 4 spaces.

● This will be the same for each key press● You will also need to choose the right axis (x

or y)

Page 8: Scratch

Solution

● Notice that it is repeated for each key press

● Left and right use x● Up and down use y

Page 9: Scratch

Activity

● Create a new scratch file● Create a sprite with 4 costumes (up, down,

left and right)● Import your spite and costumes● Get your sprite to move!

Page 10: Scratch

Finding a sound loop

● Do a search for “sound loops” to find a short bit of music to play.

● Flash kit is a great place to start

Page 11: Scratch

Import sound

● You can import a WAV or MP3 file

● This is imported into a sprite the same way a costume is

Page 12: Scratch

On click play some music!

● To play the sound we need the code on the right.

● Note that the colours represent the section each command came from.

● You could loop the sound if you wanted to!

Page 13: Scratch

Activity 2

● Add music when you click on your sprite