In-game alerts, rewards and status messages for browser games. A tested toast queue with kinds (info, reward, warning, error, banner), priorities that let urgent messages through, merging repeated messages into one ("+12 coins"), a limit on what's on screen, pausing with the game, achievement banners, reduced-motion versions, and a screen-reader live region; plus what deserves a notification, w...
Download skill (.zip) Files on GitHubGame notifications
What deserves one
| Show | Don’t |
|---|---|
| Achievement, unlock, level up (banner) | Every coin (merge them, or use a floating number at the coin: game-hud-development) |
| Checkpoint saved, quest updated | Things the player just did and can see |
| Warnings: low health, connection lost, storage full | Debug messages |
| Errors with what to do (“Couldn’t save. Free some space.”) | Errors with codes only |
assets/notify.js
import { createNotifications, createLiveRegion } from "./notify.js";
const notes = createNotifications({ maxVisible: 3, liveRegion: createLiveRegion() }); // live region: screen readers hear them
notes.push({ text: "Checkpoint", kind: "info" });
notes.push({ key: "coins", amount: 5, format: (n) => `+${n} coins`, kind: "reward" }); // merges while visible
notes.push({ text: "Achievement: Untouchable", kind: "banner" });
notes.push({ text: "Connection lost. Reconnecting…", kind: "error", key: "net" }); // priority: shown first
each frame: notes.update(dt); notes.draw(ctx, { x: W - 16, y: 70, width: 280, screenWidth: W, reducedMotion });
pause menu open: notes.pause(true)
- Same
keywhile visible or waiting updates the existing toast instead of adding one. - Errors and warnings go before normal messages and push the oldest normal one out early.
- Banners show centered and bigger; others stack in a corner.
- The queue holds 20; the least important are dropped first.
Wording and timing
- Under 6 words. Start with the thing: “Sword found”, “Level 5”.
- 2 s for info, 3-4 s for warnings and errors, longer for anything with an action.
- Top right (or top center for banners), away from the HUD and touch controls; not over the player.
- Sound for rewards and warnings, quiet; nothing for info.
Tested
Node tests: merging by key, max visible with a queue, urgent messages getting through, expiry, pausing, drawing toasts and banners, the live region. Used in the UI kit demo (merging gem counts, warnings, banners).
Pitfalls
Ten “+1 coin” toasts at once, toasts covering the HUD or the player, important messages that disappear before they’re read, notifications that keep counting down while paused, and no screen-reader option for HTML games.