Today, we’re building on our interactive coding skills by learning a great trick to make objects disappear, simulating an action like eating! We’ll be combining the Start on Tap block (for user interaction) with the Hide block and a slight movement to create a fun animation.
Our project demonstrates this by having Kitten eat the peach that fell from the tree. As Kitten eats it, the peach will rotate slightly and then vanish into their belly!
Setting the Scene and Characters
We need the right background and characters to make the illusion work.
- Change the Background: Select the summer background where the peach tree is located. [00:23]
- Add the Peach: Add the Peach character to the project. [00:35]
- Position Characters: Move the Peach so it looks like Kitten is holding it. For the best effect, try to position Kitten slightly in front of the Peach so the Peach disappears behind Kitten as it’s “eaten.” [01:54]
We will only be coding the Peach icon, as it is the object that performs the action.
Coding the Peach: The Interactive Disappearance
The Peach’s script will only begin once you tap it, making the “eating” process interactive.
- The Trigger Block: Go to the yellow category and select the Start on Tap block. This ensures that the code runs only when the user taps the peach. [01:07]
- The Nibble Movement: Go to the blue Motion category and add the Turn Left block. Change the number to 2(instead of the default 1). This slight turn makes the peach wiggle or rotate, creating the illusion of Kitten taking a bite. [01:38]
- The Disappearance: Immediately follow the turn block with the Hide block from the purple Looks category. This makes the peach instantly disappear. [01:25]
- End: Finish the script with the red End block. [01:32]
Running the Interactive Sequence
Once the code is complete, press the Reset button (to the left of the Green Flag). To start the action, simply tap the Peach on the screen. The Peach will briefly wiggle and then vanish, simulating Kitten eating the fruit! [01:44]
This project is a great example for our coding tutorials on how to use user-triggered events to create simple, effective animations. Mastering the Start on Tap block and the Hide block is a key step toward creating more interactive stories and games. For structured activities, explore our collection of ready-made lessons. Happy coding!