Bash.tv → GitHub → itch.io

Scene transitions and UI motion for browser games. A tested transition controller with fade, wipe, iris (circle closing on a point), slide, pixel dissolve and flash, the scene swap at the fully covered middle, input locked while it runs, interruption that never skips a swap, reduced-motion fallback to a short fade, plus tweens and easing for menus and buttons; when to use which transition and h...

Download skill (.zip) Files on GitHub

Game transitions

assets/transitions.js

import { createTransitions, createTweens, EASE } from "./transitions.js";
const tx = createTransitions({ reducedMotion: settings.get("reducedMotion") });
tx.start("iris", { duration: 0.6, focus: { x: player.screenX, y: player.screenY }, at: () => scenes.switch("play"), done: () => {} });
loop: tx.update(dt); if (!tx.blocking) scene.update(dt); scene.draw(ctx); tx.draw(ctx, W, H);
const tw = createTweens(); tw.tween(panel, { y: 120 }, 0.3, EASE.outBack); each frame: tw.update(dt)

at runs at the middle, when the screen is fully covered, so the old scene is never seen half-replaced. Starting a new transition while one runs still runs the pending at.

Which and how long

Moment Transition Time
Menu → game Fade or iris on the play area 0.4-0.6 s
Death → game over Iris on the player, pixels, or a slow fade 0.6-1.0 s
Retry Fast wipe or fade (players want to be back) 0.3 s
Level complete → next Wipe in the direction of travel 0.5 s
Big hit, explosion Flash (very short, can be turned off) 0.1 s
Menus, buttons Tweens: slide 20-40 px, scale 0.95→1 with EASE.out 0.15-0.3 s

Keep transitions under a second, faster for actions players repeat. Never put a transition between pressing Retry and playing that the player can’t skip.

Reduced motion and flashes

With reduced motion on, every transition becomes a fade of at most 0.3 s, and tweens can use duration 0.01. Flashes must respect the “flashing effects” setting, and never flash more than 3 times a second (seizure safety).

Tested

Node tests: cover rising and falling, input blocked, the swap exactly at the middle, done callback, interruption still swapping, all six styles drawing, reduced motion turning iris into a short fade, tweens and easing end values. Used in the UI kit demo (iris into play, pixels at game over, wipe on retry).

Pitfalls

Swapping the scene before the screen is covered, accepting input mid-transition (double-starting a level), long transitions on retry, flashing that can’t be turned off, and transitions that depend on frame rate (all of these use dt).