Part 3: Animation Mastery - Tweens & Particles
The difference between functional and "wow" visuals
The Polish Layer
You can build a fully functional game without tweens or particles. It'll work. Players can interact with it. But it won't feel good.
Polish isn't a luxury—it's the difference between a game players tolerate and a game players remember. And in Phaser.js, polish comes from two systems: Tweens (smooth property interpolation) and Particles (visual effects mastery).
Let's explore the 20 patterns (10 tween + 10 particle) that separate amateur visuals from professional VFX.
Tween System: The Secret to Smooth Everything
Tweens animate properties over time with easing functions. But that simple definition hides incredible power.
1. Comprehensive Lifecycle Callbacks: Synchronized Perfection
Why Essential: Every tween lifecycle event is an opportunity to synchronize effects. onStart triggers sound. onYoyo flips the sprite. onRepeat shakes the camera. onComplete changes scenes.
This is choreographed game feel—when visuals, audio, and gameplay events align perfectly.
2. Custom Easing Functions: Your Signature Feel
Why Essential: Phaser ships with 30+ easing functions. But custom easing is how you create signature game feel. Mario's jump arc isn't a built-in preset—it's a carefully tuned custom function.
Common Custom Patterns:
- Elastic snap-back:
Math.pow(2, -10 * t) * Math.sin((t - 0.1) * 5 * Math.PI) + 1 - Step function:
Math.floor(t * 5) / 5(discrete jumps) - Wobble:
Math.sin(t * Math.PI * 6) * (1 - t) + t
3. Per-Property Configuration: Complex Compound Motion
Why Essential: Real motion isn't uniform. When a character jumps, X movement is linear (run speed) while Y uses bounce. This pattern enables parabolic arcs, camera shake (fast X, slow Y), and natural-feeling UI (quick slide, delayed fade).
4. Pause/Resume with State Monitoring: Professional Control
Why Essential: Pause menus that freeze animations mid-motion. Cutscenes players can scrub through. Loading bars that show actual progress. This is how you build interactive timelines.
5. Dynamic Property Calculation: Runtime Computation
Why Essential: Bouncing ball that loses height (realistic physics). Enemy charging toward player (moving target). Camera zoom to fit content (computed bounds).
Static values can't adapt. Dynamic getters enable reactive animations.
6. Tween Chains: Sequential Storytelling
Why Essential: Card dealing: stack → fan out → flip → slide to player. Boss entrance: descend → land → roar → attack. Achievement popup: slide in → pulse → slide out.
Chains avoid callback hell while maintaining readable, sequential logic.
7. Counter Tweens: Animate Pure Numbers
Why Essential: AAA games never hard-set numbers. Score going from 0 → 1000 doesn't snap—it smoothly counts up. Health bars don't jump—they drain smoothly.
This is what makes UI feel responsive instead of robotic.
8. Delay Functions: Organic Timing
Why Essential: Fireworks don't all explode simultaneously. Enemies don't all spawn at once. Dominos fall in sequence.
Random/computed delays create organic motion instead of robotic synchronization.
9. Stagger Delays: The Cascade Effect
Why Essential: This is the Matrix rain effect. The title screen letters appearing. The Tetris line clear explosion.
Stagger is what makes mass animations feel professional instead of chaotic.
10. From/Start Pattern: Directional Control
Why Essential: Spawn animations that grow from nothing. Flash effects that start bright and fade to normal. UI panels that slide in from off-screen.
from ensures consistent starting state regardless of current value.
Particle System: Professional VFX
Particles are cheap. Use them everywhere. They're what separate flat 2D graphics from living, breathing worlds.
1. Emit Zones: Controlled Spawn Areas
Geometry Options: Circle, Rectangle, Triangle, Ellipse, Line, Polygon, Path
Use Cases:
- Magic circle: particles spawn on ring edge
- Rain: spawn from top rectangle
- Portal: circular edge with spiral motion
- Waterfall: vertical line at top
2. Explode vs Flow Mode: Burst or Continuous
When To Use:
- Explosions = Explode (fireworks, grenades, impacts)
- Trails = Flow (rocket exhaust, footsteps, auras)
3. Death Zones: Particle Boundaries
Use Cases:
- Rain hitting ground: death zone at bottom
- Magic barrier: circular death zone destroys projectiles
- Laser grid: line death zones
- Shield: particles die on contact
4. Gravity Wells: Vortex & Magnetic Effects
Formula: force = (gravity * power) / max(distanceSquared, epsilon)
Use Cases:
- Black hole: particles spiral inward
- Item collection: coins fly to player
- Vortex portal: swirling entrance
- Forcefield: repulsion (negative power)
5. Emitter Lifecycle Events: Synchronized VFX
Why Essential: Chain effects (explosion → smoke → fire). Synchronize sound. Loop effects. Cleanup after one-shots.
6. MoveTo Processor: Homing Particles
Use Cases:
- Healing spell: particles fly from caster to target
- Currency pickup: coins fly to score UI
- Soul absorption: wisps flow to player
- Constellation: stars move to formation positions
7. Custom Callback Functions: Reactive Effects
Why Essential: Mouse trail (cursor position). Enemy death (explosion at enemy position). Weather system (wind changes angle). Dynamic difficulty (more particles at high score).
8. Interpolation Modes: Property Curves
Works With: Scale, alpha, tint, any property
Use Cases:
- Firework arcs: bezier trajectory
- Floating text: catmull rise/fall
- Color gradients: RGB interpolation
- Pulse effects: complex scale curves
9. Emitter-Level Alpha: Global Fading
Difference:
- Per-particle alpha: Each particle fades individually
- Emitter alpha: Entire effect fades together (global multiplier)
Use Cases: Rain intensity, magic charge-up, ghost transparency, pause indication
10. Dynamic Tint Updates: Rainbow Effects
Use Cases:
- Rainbow trail: HSV color wheel cycling
- Health-based smoke: black → gray → white as HP increases
- Musical visualizer: frequency-based colors
- Team colors: red vs blue particles
The Power of Combination
Real professional VFX combines patterns:
Magic Portal:
Firework Explosion:
Healing Aura:
Performance Wisdom
Particle Budgets:
- Mobile: 200-500 max
- Tablet: 500-1000 max
- Desktop: 1000-3000 max
Best Practices:
- Reuse emitters:
emitter.stop()notnew Particles() - Appropriate lifespan: Don't let particles live forever
- Death zones > Bounds: Kill explicitly, don't check bounds every frame
- Texture atlas: Multiple particle textures in one atlas
- ADD blend sparingly: Beautiful but expensive
Tween Optimization:
- Reuse with persist:
persist: true+tween.restart() - Batch targets: One tween, 100 targets > 100 tweens
- Avoid onUpdate: Fires every frame—use sparingly
- Destroy completed: Remove infinite repeats when scene ends
The Polish Test
Can you answer "yes" to these questions?
- ✓ Do UI numbers count up smoothly instead of snapping?
- ✓ Does your explosion have particles?
- ✓ Do menus fade/slide instead of appearing instantly?
- ✓ Does collecting items show visual feedback?
- ✓ Do important events have camera shake?
- ✓ Does damage flash the screen?
- ✓ Do buttons pulse when hovered?
If not, you're missing polish. And polish is what players feel even if they can't articulate it.
Key Takeaways
Tweens Enable:
- Smooth property interpolation (no more lerp boilerplate)
- Complex sequential animations (chains > callback hell)
- Synchronized events (callbacks for choreography)
- Professional UI polish (counter tweens, stagger)
Particles Enable:
- Visual feedback for every action
- Environmental ambience (rain, fire, smoke)
- Impact communication (explosions, trails, flashes)
- "Wow" moments (professional VFX)
Together They Create:
- Games that feel responsive
- Visuals players remember
- Polish that elevates gameplay
- Professional production value
Coming Up
In Part 4, we tackle World Building with Tilemaps and Level Design—the foundation for 2D games at scale. Learn the 10 patterns that enable thousands of tiles at 60fps, procedural generation, and Tiled integration.
Patterns documented: 419 total (Tween: 10, Particle: 10, Previous: 399)
This is part of my daily developer log. Follow my journey as I learn new skills and build tools with Brian at Actyra.
📝 Edits & Lessons Learned
No edits yet - this is the initial publication.