Events and Looks Blocks(Say Block)
1. Keypress Events
Definition: A keypress event happens when you press a key on your keyboard, and the sprite follows an action. It tells Scratch to listen for a key and respond to it.
Why use it?
- Keypress events help make games and animations interactive.
- They allow players to control a sprite using the keyboard.
- This makes the sprite move, jump, or perform actions when certain keys are pressed.
- Enables keyboard-based interaction.
- Useful in games and animations.
Example (Code):
- Pressing the left arrow key moves the sprite left.
- Pressing the right arrow key moves the sprite right.
- Pressing the up arrow key moves the sprite up.
- Pressing the down arrow key moves the sprite down.
- Pressing the spacebar makes the sprite jump.
How to Teach?
- Ask students to experiment with different keypresses.
- Demonstrate how pressing different keys triggers actions.
2. Say and Think Block
Definition:
- Say Block (Timed): Displays a speech bubble for a set number of seconds and then disappears.
- Say Block (Non-Timed): Displays a speech bubble indefinitely until another block removes it.
- Think Block (Timed): Displays a thought bubble for a set number of seconds.
- Think Block (Non-Timed): Displays a thought bubble indefinitely.
The Say Block is used to make the sprite talk, while the Think Block is used for thoughts or silent expressions.
Why use it?
- Helps create dialogues in animations and games.
- Makes characters more interactive.
Example:
- Say Block (Timed): Displays a speech bubble for 2 seconds and disappears.
- Say Block (Non-Timed): Displays a speech bubble indefinitely until another block removes it.
- Think Block (Timed): Displays a thought bubble for 2 seconds and disappears.
Think Block (Non-Timed): Displays a thought bubble indefinitely until another block removes it.
How to Teach?
- Show how to use the Say Block with keypress events.
- Encourage students to create dialogues for their sprite.
- Ask students to add different messages for different keypresses.
Final Mini-Project: Talking Character with Movement
Objective: Create a character that moves and talks based on user input while also including previous concepts learned in earlier classes.
Steps to Create the Project:
- Choose a sprite (e.g., a cat or a person).
- Set initial position: Move the sprite to the starting position.
- Make the sprite move:
- Pressing the down arrow key moves it down.
- Pressing the left arrow key moves it left.
- Pressing the right arrow key moves it right.
- Pressing the up arrow key moves it up.
- Make the sprite talk:
- When clicked, it says a message.
- Different keys make it say different phrases.
- Add Random Movement:
- Pressing the spacebar makes the sprite glide to a random position.
- Run the project and test interactions.
✅ Expected Outcome: The sprite moves, talks, and interacts with random movements when different keys are pressed.