Hello, parents and teachers! Are you looking for a fantastic way to make your coding projects truly interactive? Today, we are diving into the world of collision detection in ScratchJr! We’ll learn how to use the powerful Start on Bump block to trigger a programme when two characters touch, and we’ll also learn how to animate a character using the Turn block.
The project we’re building is a fun game of football: Kitten will move and kick a football towards a Penguin. This teaches children how to create cause-and-effect sequences in their coding.
Setting Up Your Interactive Scene
First, let’s get our players and our pitch ready:
- Change the Background: Select the park background as the setting for our football game. [00:26]
- Add Characters: Introduce the three necessary characters: Kitten, the Penguin, and the Football. [00:40]
- Position Characters: Arrange them so they look like they’re ready to play! Place the Football between Kitten and the Penguin, ensuring Kitten is facing the ball. [01:01]
Coding Kitten: The Trigger Action
We need to programme Kitten to walk towards the ball and “wind up” for the kick. Since Kitten’s action starts the entire sequence, we use the Green Flag.
- Start Block: Use the Green Flag trigger block from the yellow category.
- Move to the Ball: Use the Move Right block from the blue category to make Kitten walk until they are touching the Football. You’ll need to adjust the number until Kitten reaches the ball. [01:30]
- Wind Up: Use the Turn blocks from the blue category to make Kitten rotate (turn and return) to create a visual “wind up” or preparation for the kick. [01:38]
- End Block: Finish Kitten’s script with the red End block.
Coding the Football: The Start on Bump Block
This is where the magic happens! We need to programme the Football to move only when Kitten touches it. Select the Football icon to build its scripts.
Program 1: Horizontal Movement (The Goal Kick)
This script will make the ball roll across the pitch toward the Penguin.
- Start on Bump: Go to the yellow category and select the Start on Bump block (the two arrows pointing towards each other). This ensures the script activates only when the Football is touched by another character. [02:41]
- Move Across: Use the Move Right block from the blue category to send the ball towards the Penguin. You can set the number (e.g., 7) to control how far it travels. [02:54]
- End Block: Complete the script with the red End block.
Program 2: Vertical Movement (The Chip Up)
To make the kick look realistic, we want the ball to chip up slightly as it is hit.
- Second Start on Bump: Start a new, separate script with a second Start on Bump block. This allows the ball to run both the horizontal move and the chip up simultaneously. [03:13]
- Move Up: Use the Move Up block from the blue category, setting a small number for a subtle chip. [03:21]
- End Block: Finish with the red End block.
Now, when you press the Green Flag, Kitten will walk to the ball, and the moment they bump it, the two scripts for the Football will activate, making the ball roll and chip up toward the Penguin! [03:56]
Learning these ScratchJr blocks is a huge step in creating dynamic, interactive animations. If you’re looking for more guidance, check out our coding tutorials for more step-by-step projects. For detailed educational content, explore our comprehensive lessons designed for the classroom. Happy coding!