@nanoforge-dev/sound
v1.0.1
Published
NanoForge Engine - Sound
Readme
About
@nanoforge-dev/sound is a sound manager for your game.
Installation
Node.js 24.11.0 or newer is required.
npm install @nanoforge-dev/sound
yarn add @nanoforge-dev/sound
pnpm add @nanoforge-dev/sound
bun add @nanoforge-dev/soundExample usage
Initialize the library in your main file
import { AssetManagerLibrary } from "@nanoforge-dev/asset-manager";
import { type IRunClientOptions } from "@nanoforge-dev/common";
import { NanoforgeFactory } from "@nanoforge-dev/core";
import { SoundLibrary } from "@nanoforge-dev/sound";
export async function main(options: IRunClientOptions) {
const app = NanoforgeFactory.createClient();
const assetManager = new AssetManagerLibrary();
const sound = new SoundLibrary();
app.useAssetManager(assetManager);
app.useSound(sound);
await app.init(options);
sound.load("sound", assetManager.getAssetPath("/path/to/sound.mp3").path);
await app.run();
}Use to play sound
export function mySystem(registry: Registry, ctx: Context) {
const assetManager = ctx.libs.getAssetManager<AssetManagerLibrary>();
const sound = ctx.libs.getSound<SoundLibrary>();
sound.play("sound");
}Links
Contributing
Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the
documentation.
See the contribution guide if you'd like to submit a PR.
Help
If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle nudge in the right direction, please don't hesitate to ask questions in discussions.
