Snow Globe in MIT App Inventor | Snow effect in MIT App Inventor | Special effects in App Inventor
Based on Obsidian Soft's video on YouTube. If you like this content, support the original creators by watching, liking and subscribing to their content.
Set the snowflake sprite to move downward using heading 270, with interval 100 ms and speed 5 pixels per tick.
Briefing
A holiday “snow globe” app built in MIT App Inventor turns phone shakes into falling snow—complete with a wintry background, multiple animated snowflakes, and music that starts when the device moves. The core mechanism is simple: an accelerometer detects shaking, then a set of snowflake sprites becomes visible and falls downward until each one hits the bottom edge and disappears.
The project starts by creating a new App Inventor project named “snow globe,” then uploading a background image (chosen from a wintry scene with a snowman, with options for other Christmas or city images) and a short music file. The music is trimmed to about 15 seconds so it won’t keep playing after the snow effect ends. Screen properties are set for a portrait layout, the title bar is hidden, and a canvas is added as the main drawing surface. A player component is configured to play the uploaded music “only in foreground,” and an accelerometer sensor is added to detect device motion.
For the snow effect, a ball sprite is used as a snowflake. Its heading is set to 270 degrees so it moves downward, with an interval of 100 milliseconds and a speed of 5 pixels per tick. The sprite’s paint color is set to white. Because one snowflake isn’t enough, the ball sprite is duplicated repeatedly until there are 25 instances. Rather than writing separate logic for each sprite, the build leans on abstraction: a single procedure and “any ball” generic blocks let the same code apply to every snowflake.
A custom procedure named “give random position and size to ball” takes a ball as input and assigns it a random radius (between 4 and 6), a random X position (between 10 and canvas width minus 10), and a random Y position (between 50 and canvas height minus 200). A global “ball list” is created to hold all 25 sprites. When the screen initializes, the app populates this list with Ball 1 through Ball 25.
When the accelerometer detects shaking (the “when checking” event), the app loops through every item in the ball list. For each snowflake, it calls the random-position procedure and sets the sprite visible to true, making the snow appear only during motion. A second abstraction step handles cleanup: each ball’s “edge reached” event hides that specific sprite (setting visible to false) once it falls off the bottom. Finally, the music starts at the same moment as the shake-triggered loop by calling player.start just before the loop begins.
The result is a compact but flexible snow animation: shake the device to spawn randomized falling snow, let sprites vanish at the bottom, and keep the audio aligned with the effect duration—while using abstraction to avoid repetitive code across 25 separate sprites.
Cornell Notes
The snow globe app uses MIT App Inventor sprites plus an accelerometer to create falling snow that appears only when the device shakes. A ball sprite is configured to move downward (heading 270) at a set speed and interval, then duplicated to create 25 snowflakes. Abstraction reduces repetition: a single procedure assigns each snowflake a random radius and starting position, and generic “any ball” blocks apply visibility and edge-reached behavior to all 25 sprites. A ball list stores every snowflake, and a loop activates them on shake while hiding each one again when it reaches the bottom. Music starts when shaking begins, using a short audio clip so it doesn’t outlast the snow effect.
How does the app make snowflakes fall downward in MIT App Inventor?
Why duplicate the ball sprite up to 25 instances, and how are they managed efficiently?
What does the random-position-and-size procedure do, and how does it keep sprites on-screen?
How does shaking trigger the snow effect, and what happens to each snowflake afterward?
How is the music synchronized with the snow, and why is the audio shortened?
Review Questions
- What specific abstraction blocks are used to apply the same edge-reached and visibility logic to all 25 snowflake sprites?
- How do the random X and Y ranges (including the canvas width/height offsets) prevent snowflakes from spawning too close to edges?
- Describe the sequence of events from accelerometer shake to snowflake disappearance, including which properties change and when.
Key Points
- 1
Set the snowflake sprite to move downward using heading 270, with interval 100 ms and speed 5 pixels per tick.
- 2
Duplicate the snowflake sprite until there are 25 instances, then store them in a global ball list for batch control.
- 3
Use a single procedure to assign each snowflake a random radius (4–6) and starting position constrained by canvas width and height offsets.
- 4
Trigger snow appearance only on accelerometer shake by looping through the ball list and setting each ball.visible to true.
- 5
Hide each snowflake when it reaches the bottom by using generic “any ball” edge-reached handling to set visible to false.
- 6
Start music at the same moment shaking begins, and keep the audio short (about 15 seconds) to match the snow effect duration.