Back to Experiments

Emoji Loading Screen

SpriteKit physics simulation with falling emoji, gyroscope tilt, and customisable themes

SpriteKitPhysicsSwiftUIiOSCoreMotion4 min
๐ŸŽ
๐Ÿ•
๐Ÿฉ
๐ŸŒฎ
๐Ÿ”
๐Ÿง
๐ŸŸ
๐Ÿฃ
๐Ÿฐ
๐ŸŒฏ
๐Ÿฅ
๐Ÿ—
๐Ÿ‹
๐Ÿฅ‘
๐ŸŠ
๐Ÿ“
๐Ÿง€
gravity

A playful SpriteKit physics simulation where emoji fall, collide, bounce, and pile up with realistic gravity. Responds to device tilt via the gyroscope. Fully reusable as a loading screen, onboarding animation, or interactive element with customisable emoji sets, spawn rates, and physics parameters.

Overview

A SpriteKit physics simulation where emoji fall from the top of the screen, collide, bounce, and pile up with realistic gravity. The device gyroscope tilts the gravity vector so emojis roll and tumble when you move your phone. Built for Shopa as a playful loading screen during recipe imports, it's fully reusable for any loading state, onboarding animation, or fun interaction.

Grab the Code

Use the food emoji version as-is, or grab the reusable version for custom emoji sets and configurable physics. Preview any file before copying.

EmojiPhysicsScene.swiftSwift

SpriteKit scene with physics, spawning, gyroscope, and cleanup

EmojiPhysicsView.swiftSwift

SwiftUI wrapper (UIViewRepresentable for SKView)

EmojiPhysicsScene+Reusable.swiftSwiftOptional

Generalised version with custom emoji sets, spawn rate, gravity, and limits

Features

๐ŸŽฒ

Random Spawning

Emojis spawn at random X positions with varied sizes (40โ€“70pt), velocities, and angular momentum

๐Ÿ“ฑ

Gyroscope Tilt

CoreMotion accelerometer data dynamically adjusts gravity so emojis respond to device orientation

๐Ÿ’ฅ

Collision Physics

Circular physics bodies with customisable mass, restitution, friction, and damping for realistic stacking

โœจ

Pop-in Animation

Each emoji scales from 0.1 to 1.0 with a fade-in on spawn, and fades out with scale-down on stop

๐Ÿงน

Memory Management

Auto-removes oldest emojis when count exceeds 100. Full cleanup on dismiss prevents memory leaks

๐Ÿ”ฒ

Transparent Overlay

Renders with a clear background so it overlays on top of any existing UI without blocking touches

Quick Start

Usage.swiftswift
struct RecipeImportView: View {
    @State private var isImporting = true

    var body: some View {
        ZStack {
            // Your content underneath
            VStack {
                ProgressView()
                Text("Importing recipe...")
            }

            // Emoji physics overlay
            if isImporting {
                FoodEmojiPhysicsView(isAnimating: $isImporting)
                    .transition(.opacity)
            }
        }
    }
}

// Custom emoji set example
struct PartyLoader: View {
    @State private var isLoading = true

    var body: some View {
        ZStack {
            Color.black.ignoresSafeArea()

            EmojiPhysicsView(
                isAnimating: $isLoading,
                emojis: ["๐ŸŽ‰", "๐ŸŽŠ", "๐Ÿฅณ", "๐ŸŽˆ", "๐ŸŽ", "โœจ", "๐Ÿ’ซ", "โญ๏ธ"],
                spawnInterval: 0.3,
                gravity: -6.0,
                maxEmojis: 80
            )
        }
    }
}

Customisation Ideas

Different emoji themes

Swap the emoji array for any theme: sports (โšฝ๏ธ๐Ÿ€๐ŸŽพ), weather (โ˜€๏ธ๐ŸŒง๏ธโ„๏ธ), animals (๐Ÿถ๐Ÿฑ๐Ÿฐ), holiday (๐ŸŽ„๐ŸŽ…๐ŸŽ), etc.

Adjust physics

baseGravity controls fall speed (-4.5 default). restitution controls bounciness (0.2โ€“0.4 recommended for stacking). gravityMultiplier scales the gyroscope effect.

Spawn rate

The timer interval (0.4s default) controls how fast emojis appear. Try 0.2s for a rapid fill or 0.8s for a gentler effect.

Disable gyroscope

Remove the startMotionUpdates() call for a static gravity simulation. Useful for iPads or when device motion isn't wanted.

Products
Josh
Speaking
Experiments