Loads a sheet written as a file: the image, how it is cut into frames, and the named runs of frames over it.
useLoadAtlas(options: TUseLoadAtlasOptions) => TLoadedAtlas
Ejemploexport const Level: TSceneFn = () => {
const coin = useLoadAtlas({ src: '/assets/atlases/coin.atlas' });
const sprite = createSprite({ atlas: coin, transform: { x: 160, y: 120 } });
// The runs come from the file, so the clip is not written twice.
useSpriteAnimation(sprite, { clips: coin.sequences, play: 'spin' });
return createScene();
};
Ficha completa en la referenciaLoads a sound, and hands it back at once, still loading, for useSound to play.
useLoadAudio(options: TUseLoadAudioOptions) => TAudioClip
Ejemplodeclare const chest: TSprite;
export const Level: TSceneFn = () => {
const coin = useLoadAudio({ src: '/audio/coin.mp3', key: 'coin' });
const pickup = useSound(coin);
listen(chest, { onClick: () => pickup.play() });
return createScene();
};
Ficha completa en la referenciaKeeps count of what a scene is loading, for a loading bar or to wait before changing scene.
useLoader(assets?: typeOperator) => TLoader
Ejemploexport const Loading: TSceneFn = () => {
const scene = useScene();
const loader = useLoader([
useLoadTexture({ src: '/assets/hero.png', key: 'hero' }),
useLoadTexture({ src: '/assets/tiles.png', key: 'tiles' }),
]);
const bar = createSprite({ width: 0, height: 8, transform: { x: 60, y: 112 } });
useUpdate(() => {
bar.width = loader.progress * 200;
if (loader.done) scene.change('Level');
});
return createScene();
};
Ficha completa en la referenciaLoads a bitmap font: an image with the characters drawn in it, and a file saying where each one is.
useLoadFont(options: TUseLoadFontOptions) => TFont
Ejemploexport const Title: TSceneFn = () => {
const font = useLoadFont({
json: '/fonts/arcade/arcade.json',
atlas: '/fonts/arcade/arcade.png',
});
createText({ text: 'PRESS START', font, transform: { x: 16, y: 16 } });
return createScene();
};
Ficha completa en la referenciaLoads a model made somewhere else: something sculpted in Blender, bought in a pack, exported from anywhere that writes glTF.
useLoadGltf(options: TUseLoadGltfOptions) => TGltfModel
Ejemploexport const Level: TSceneFn = () => {
useCamera3d({ projection: 'perspective', z: 6 });
useLight({ intensity: 1 });
const tower = useLoadGltf({ src: '/models/tower.glb' });
const placed = createModel({ model: tower });
useUpdate((delta) => {
placed.transform.rotationY += delta * 0.5;
});
return createScene();
};
Ficha completa en la referenciaLoads a colour grading table.
useLoadLut(options: TUseLoadLutOptions) => TLut
Ejemploconst evening = useLoadLut({ src: '/luts/evening.cube' });
usePostProcess({ ...lutGrade({ amount: 0.8 }), lut: evening });
Ficha completa en la referenciaLoads a pack: boxes and scenes somebody made in another project, with everything they need.
useLoadPack(options: TUseLoadPackOptions) => TLoadedPack
Ejemploconst Plaza: TSceneFn = () => {
const signs = useLoadPack({ src: '/packs/signpost' });
createPack({ pack: signs, box: 'Signpost', transform: { x: 100, y: 120 } });
return createScene();
};
Ficha completa en la referenciaLoads a set of colours for an effect to match a frame against.
useLoadPalette(options: TUseLoadPaletteOptions) => TPalette
Ejemploconst nes = useLoadPalette({ src: '/palettes/nes.palette' });
usePostProcess({ ...paletteMatch(), palette: nes });
Ficha completa en la referenciaLoads an effect: what a puff of smoke or a shower of sparks is made of.
useLoadParticles(options: TUseLoadParticlesOptions) => TParticlesFile
Ejemploconst fire = useLoadParticles({ src: '/effects/fire.particles' });
createParticles({ effect: fire, transform: { x: 150, y: 250 } });
Ficha completa en la referenciaLoads a shader written in a file, so an effect can live beside the game instead of inside it.
useLoadShader(options: TUseLoadShaderOptions) => TShader
Ejemploexport const Level: TSceneFn = () => {
const crt = useLoadShader({ src: '/shaders/crt.wgsl' });
const texture = useLoadTexture({ src: '/assets/hero.png' });
createSprite({ texture, material: createMaterial({ effect: crt, uniforms: { lines: 80 } }) });
return createScene();
};
Ficha completa en la referenciaLoads an image to draw with, and hands it back at once, still loading: a sprite made with it appears by itself when the file arrives, so nothing has to wait for it.
useLoadTexture(options: TUseLoadTextureOptions) => TTexture
Ejemploexport const Level: TSceneFn = () => {
const hero = useLoadTexture({ src: '/assets/hero.png', key: 'hero' });
createSprite({ texture: hero });
return createScene();
};
Ficha completa en la referencia