Cue type
export type Cue = "fire" | "hit" | "boom" | "hurt" | "power" | "ready" | "win" | "end" | "click";
SOUND V0.10.0
fizlet/soundThe sound adapter. After each frame it reads the engine's event ring and plays the mapped cues, so collisions and game events make sound without knowing about audio. The default voice is a tiny synth (oscillators, no assets); pass play to use your own sounds. Silent until the first trusted gesture, while paused, and when switched off.
Measured on this build: minified and gzipped with everything it imports, the way npm run size checks the budget in CI.
import { sound } from "https://coded-dot-design.github.io/fizlet/dist/sound.js";npm install fizlet # not published yet
import { sound } from "fizlet/sound";const sfx = sound(e, { cues: { boom: "boom" } });
e.events.emit("boom"); // in a step; plays after render
sfx.on = false; // muteEvery export, with its doc comment, read from the published type declarations of v0.10.0.
Cue typeexport type Cue = "fire" | "hit" | "boom" | "hurt" | "power" | "ready" | "win" | "end" | "click";
SoundOptions interfaceexport interface SoundOptions {
/** event type → cue, e.g. { shot: "fire", wreck: "boom" }. */
cues: Record<string, Cue>;
/** Start switched on (default true). */
on?: boolean;
/** Master volume 0..1 (default 0.12). */
volume?: number;
/** Your own player instead of the synth. */
play?: (cue: Cue, intensity: number) => void;
}
sound functionexport declare function sound(e: Engine, o: SoundOptions): {
play: (cue: Cue, intensity?: number) => void;
dispose: () => void;
on: boolean;
};
Sound typeexport type Sound = ReturnType<typeof sound>;