@yagejs/save
v0.1.0
Published
Save and load game state for YAGE
Maintainers
Readme
@yagejs/save
Save and load game state for the YAGE 2D game engine.
Install
npm install @yagejs/saveUsage
import { Engine } from "@yagejs/core";
import { SavePlugin, SaveServiceKey } from "@yagejs/save";
const engine = new Engine();
engine.use(new SavePlugin());Mark components as serializable and save the world:
import { serializable } from "@yagejs/core";
@serializable("player-stats")
class PlayerStats extends Component {
constructor(public hp = 100, public xp = 0) { super(); }
}
// Save
const saveService = engine.context.resolve(SaveServiceKey);
await saveService.save("slot-1");
// Load
await saveService.load("slot-1");What's in the box
- SavePlugin / SaveService - snapshot the entire engine state
- Pluggable storage -
LocalStorageSaveStorageincluded; implementSaveStoragefor custom backends (IndexedDB, files, remote, etc.) - @serializable decorator - opt components into save/load
- Typed slots - multiple save slots with metadata
Docs
Full documentation at yage.dev.
License
MIT
