Overview
The<App> component is the root of every Stake Engine game. It initialises a PIXI.Application, mounts the canvas, loads all declared assets, and exposes reactive state through the stateApp object created by createApp.
The component tree assembled by <App> is:
createApp
Create an application state object and pass it to your Svelte context before mounting<App>.
stateApp fields
The asset manifest passed to
createApp. A dictionary mapping string keys to Asset descriptors. Each descriptor has a type ('sprite' | 'sprites' | 'spriteSheet' | 'spine' | 'font' | 'audio'), a src, and an optional preload flag.Becomes
true once all non-preload assets have finished loading. Reactive — read it inside a $derived or $effect to react to load completion.A number from
0 to 100 representing the percentage of non-preload assets loaded. Useful for rendering a progress bar.A dictionary of fully processed assets keyed by the same names used in the manifest. Components such as
<Sprite>, <SpriteSheet>, and <SpineProvider> look up assets from this object using their key prop.The underlying
PIXI.Application instance. Available after <InitialiseApplication> has mounted. undefined before initialisation and after destroy.Resets
loaded, loadingProgress, loadedAssets, and pixiApplication to their initial values. Called automatically by <App> on mount and destroy.<App>
The top-level wrapper for a Stake Engine game. Place it inside a Svelte component that has calledsetContext with the result of createApp.
Props
The Svelte snippet rendered inside the fully-initialised application. Children are only rendered after
<InitialiseApplication> has created the canvas and all preload assets are available.<App> calls stateApp.reset() on both mount and destroy. This ensures the application starts from a clean state and tears down cleanly when the component is removed.<AssetsLoader>
Internal component used by<App>. Reads the asset manifest from stateApp.assets, loads any preload: true assets first (blocking render), then loads the remaining assets in the background while updating stateApp.loadingProgress.
You do not need to use <AssetsLoader> directly — <App> includes it automatically.
How asset loading works
Preload assets (preload: true) are loaded before children are rendered. Use this for assets required to display the initial frame — for example, a loading screen background.
Deferred assets (default, preload: false) are loaded after children are rendered. stateApp.loadingProgress increments as each one finishes. stateApp.loaded becomes true when all deferred assets are done.
<InitialiseApplication>
Internal component used by<App>. Creates the PIXI.Application and appends its canvas to the DOM.
The application is configured with:
| Option | Value |
|---|---|
autoDensity | true |
backgroundAlpha | 0 (transparent) |
antialias | true |
preference | 'webgpu' (falls back to WebGL) |
powerPreference | 'high-performance' |
resolution | devicePixelRatio (reactive) |
resizeTo | window |
'auto' on the canvas to prevent blocking page scroll on touch devices.
Children are rendered only after the application has finished initialising.
