Game objects
Back to the reference

Game objects

What a scene is filled with: sprites, texts, models, emitters, lines, materials, and destroying them.

81 symbols

createMaterialvariablenacatamalon

createMaterial: TCreateMaterial

Makes a material: a shader of your own, and for models the surface it is drawn over.

It is a plain value, not a resource. Nothing caches it and nothing looks it up by name, so two things share one by being handed the same one. That is also what makes a shared effect cheap: one material is one compiled shader, however many things are drawn with it, and each of those can still run it with its own numbers by passing uniforms of its own.

What it carries depends on what it is for, and the two are deliberately different. A material for models owns the surface, because a hundred crates want to share one. A material for sprites owns only the effect, because a sprite's picture and colour are its own and travel with it: putting the colour on something shared would mean one material per sprite to vary it.

Example

const Level = () => {
    const texture = useLoadTexture({ src: '/assets/hero.png' });

    const crt = createMaterial({
        fragment: `fn effect(color: vec4<f32>, uv: vec2<f32>) -> vec4<f32> {
            let band = 0.5 + 0.5 * sin(uv.y * mu.lines + mu.time * 6.0);
            return vec4<f32>(color.rgb * band, color.a);
        }`,
        uniforms: { lines: 200 },
    });

    createSprite({ texture, material: crt });

    return createScene();
};
View source · gameobjects/material/create_material.ts:123

createMeshfunctionnacatamalon

createMesh(options: TMeshOptions) => TMesh

Puts a model in the scene: a shape, somewhere, with a surface.

The shape comes from one of the shape hooks and is shared, so making a hundred of these from one shape costs a hundred placements and not a hundred shapes.

It is drawn through the scene's 3D camera, or flat on in the game's pixels when it has none. It shares its draw order with everything else, so a model can sit between two sprites, and on a tie the model is drawn first and the sprite paints over it.

What comes back is the model itself, plain data: move it, turn it, tint it, hide it.

Parameters

optionsTMeshOptions

The shape, and anything else about how it looks.

Example

const Level = () => {
    useCamera3d({ projection: 'perspective', transform: { z: 4 } });
    const crate = createMesh({ geometry: useCubeGeometry(), tint: '#c08040' });

    useUpdate((delta) => {
        crate.transform.rotationY += delta;
    });

    return createScene();
};
View source · gameobjects/mesh/create_mesh.ts:74

createMeshInstancesfunctionnacatamalon

createMeshInstances(options: TMeshInstancesOptions) => TMeshInstances

Puts many of one shape in the scene, drawn in one go: a field of grass, a hillside of rocks, a forest. One shape, one surface and one draw, however many there are, where a createMesh each would be a draw each.

What comes back is a model like any other: its transform moves them all together, its material is the surface of every one, and it is skipped, lit and sorted as one model (so keep a group to what stands together, and make another for what stands elsewhere). Each instance is placed inside it with set, with a colour and four numbers of its own; count is how many are drawn.

A material's corner hook runs after an instance is placed: pos is where the corner is in the group's space, ctx.origin where its instance stands and ctx.instance its four numbers, so wind crossing a meadow is written once for every blade. What the colour hook needs of them is handed on through carry.

It does not bend around bones, and its instances are not sorted among themselves, so see-through ones blend in the order they were set: cut them out with alphaCutoff instead where that shows.

Parameters

optionsTMeshInstancesOptions

The shape, how many there is room for, and anything else createMesh takes.

Example

const rocks = createMeshInstances({ geometry: useCubeGeometry(), tint: '#8a8f98', capacity: 500 });

for (let i = 0; i < 500; i++) {
    rocks.set(i, {
        x: Math.random() * 40 - 20,
        z: Math.random() * 40 - 20,
        rotationY: Math.random() * Math.PI,
        scale: 0.5 + Math.random(),
    });
}
View source · gameobjects/mesh/create_mesh_instances.ts:105

createModelfunctionnacatamalon

createModel(options: TModelOptions) => TModel

Puts a loaded model in the scene.

A model file is usually several pieces, each with its own colour or picture: a vehicle is a body, glass and tyres. All of them are drawn, and one placement moves the lot, however deep the file's own structure went. Where each piece sits inside the model is already worked into it.

The pieces appear when the file does. On the frame you call this the model may still be on the way, so parts is empty and nothing is drawn; a frame or two later it fills in and the model is there. Nothing has to be waited for or wired up.

tint multiplies, so the colours the model was made with survive: white leaves it exactly as it was made, and a darker colour shades all of it at once.

What comes back is used like any other drawing: tint, alpha, zIndex, castShadow and visible on it change every piece at once, and can be set straight away (a model hidden before its file arrives arrives hidden); destroy(model) takes it all. To change one piece alone, reach into parts once the file is here.

Parameters

optionsTModelOptions

The model, and anything else about how it looks.

Example

const Level = () => {
    useCamera3d({ projection: 'perspective', transform: { z: 6 } });
    useDirectionalLight({ intensity: 1 });

    const tower = useLoadModel({ src: '/models/tower.glb' });
    const placed = createModel({ model: tower, transform: { y: -1 } });

    useUpdate((delta) => {
        placed.transform.rotationY += delta * 0.5;
    });

    return createScene();
};
View source · gameobjects/model/create_model.ts:188

createNineSlicefunctionnacatamalon

createNineSlice(options: TNineSliceOptions) => TNineSlice

Puts a picture in the scene that can be any size without deforming: a panel, a button, a dialogue box, a health bar.

The picture is cut into nine parts by four borders (slice), measured in its own pixels. The corners are drawn as they are, the top and bottom edges only grow sideways, the left and right edges only grow downwards, and the middle fills the rest. So a 24x24 frame drawn at 300x80 keeps its corners crisp, which stretching it as a sprite would not.

  • mode decides how the edges and the middle fill their space: stretched (the default), repeated and cut at the end ('tile'), or repeated a whole number of times ('tile-fit'). Repeating draws one sprite per copy, so a small pattern over a large panel is many sprites.
  • Drawn smaller than its borders, the corners shrink in proportion instead of overlapping.
  • transform.scaleX/scaleY stretch the whole of it, corners included. To make it bigger and keep the corners, change width and height.

It is placed by its anchor, its middle unless you say otherwise, like a sprite, and takes the same pointer events (onClick, onPointerOver...), which fire anywhere inside it.

Parameters

optionsTNineSliceOptions

Its picture, borders, size, place and look: see TNineSliceOptions.

Example

export const Menu: TSceneFn = () => {
    useLoadTexture({ src: '/assets/ui/panel.png', key: 'panel' });
    const panel = createNineSlice({
        key: 'panel',
        slice: 8,
        width: 200,
        height: 64,
        transform: { x: 160, y: 120 },
        onClick: () => { panel.width += 16; },
    });

    return createScene();
};

Example

// The borders belong to the picture, not to each panel: write them once, and if the frame is
// redrawn there is only one number to change.
const PANEL = { key: 'panel', slice: 8 };

export const Inventory: TSceneFn = () => {
    useLoadTexture({ src: '/assets/ui/panel.png', key: 'panel' });
    createNineSlice({ ...PANEL, width: 200, height: 64, transform: { x: 160, y: 60 } });
    createNineSlice({ ...PANEL, width: 120, height: 40, transform: { x: 160, y: 140 } });

    return createScene();
};
View source · gameobjects/nine_slice/create_nine_slice.ts:88

createPackfunctionnacatamalon

createPack(options: TPackOptions) => TGameObject

Places one thing a pack offers: a box, or a scene as one part of the scene that creates it.

It appears when the pack does, the way createModel fills in when its file arrives: what comes back is the object at once, empty on the frame you call this, and the pack's box is built inside it the moment the pack has landed. Nothing has to be waited for.

Each call is its own copy, with its own place (transform) and its own settings (props), and what comes back is an ordinary object: move it, hide it, destroy it like any other. The pack's box sits inside it at the place it was made at, so a script that moves its own box keeps doing so relative to wherever you put the copy.

A script the pack's box attaches has to be registered, which is what importing the pack's <name>.pack.ts does. One that is not is named in a warning, and the box is built without it.

Parameters

optionsTPackOptions

Which thing of which pack, where, and with which settings.

Example

const Menu: TSceneFn = () => {
    const ui = useLoadPack({ src: '/packs/ui-kit' });
    createPack({ pack: ui, box: 'Button', transform: { x: 160, y: 120 } });
    createPack({ pack: ui, box: 'Button', transform: { x: 160, y: 160 }, props: { label: 'QUIT' } });
    return createScene();
};
View source · gameobjects/pack/create_pack.ts:113

createParticlesfunctionnacatamalon

createParticles(options: TParticlesOptions) => TParticles

Puts an emitter in the scene: a place that makes particles, following an effect from a file.

The file says what the effect is and is shared, so three torches reading one document are three emitters with their own particles, their own clock and their own stream of chance. What this decides is where it is, what colour it is laid in, and whether it starts lit.

It appears at once and draws nothing until its file lands, which is a working state and not a half-built one: the emitter is already in the right place, so nothing that depends on where it is has to wait for a download.

Parameters

optionsTParticlesOptions

The effect to follow, and what this emitter decides for itself.

Example

const Level = () => {
    const fire = useLoadParticles({ src: '/effects/fire.particles' });

    createParticles({ effect: fire, transform: { x: 150, y: 250 } });

    return createScene();
};
View source · gameobjects/particles/create_particles.ts:97

createParticles3dfunctionnacatamalon

createParticles3d(options: TParticles3dOptions) => TParticles3d

Puts an emitter in a scene in three dimensions, following an effect written for them.

The same thing createParticles is, one dimension up: the file says what the effect is and is shared, and this decides where it is, what colour it is laid in and whether it starts lit. Each particle is drawn as a square that always faces the camera, however the camera turns, and hides behind the models in front of it without hiding the other particles.

Its effect has to be a particles-3d file. Handing it a flat one is refused, because every number in that file is a pixel.

Parameters

optionsTParticles3dOptions

The effect to follow, and what this emitter decides for itself.

Example

const Campfire = () => {
    const fire = useLoadParticles({ src: '/effects/campfire3d.particles' });

    createParticles3d({ effect: fire, transform: { y: 0.1 } });

    return createScene();
};
View source · gameobjects/particles/create_particles_3d.ts:45

createPolygonfunctionnacatamalon

createPolygon(options: TPolygonOptions) => TPolygon

Puts a shape in the scene whose corners the game moves: a picture stretched over an outline that can change every frame. For what a rectangle cannot be: a blob that squashes as it lands, a jelly, a flag, a drop.

Each corner holds on to its point of the picture, so moving it stretches the picture under it. The corners are points, plain numbers on what comes back: change them every frame, from a physics body, a wave or anything else, and the next frame draws them. It is drawn from its middle out, so it suits outlines that can be seen whole from their middle.

Drawn in the scene's order like a sprite, through the scene's camera, in either backend.

Parameters

optionsTPolygonOptions

Its outline, picture, place and look: see TPolygonOptions.

Example

export const Pond: TSceneFn = () => {
    // A blob of twelve corners round a circle, wobbling.
    const corners = Array.from({ length: 12 }, (_, i) => ({ angle: (i / 12) * Math.PI * 2 }));
    const blob = createPolygon({
        points: corners.map(({ angle }) => ({ x: Math.cos(angle) * 24, y: Math.sin(angle) * 24 })),
        tint: '#5bd75b',
        transform: { x: 160, y: 90 },
    });

    useUpdate((_delta, time) => {
        corners.forEach(({ angle }, i) => {
            const r = 24 + Math.sin(time * 4 + angle * 3) * 3;
            blob.points[i].x = Math.cos(angle) * r;
            blob.points[i].y = Math.sin(angle) * r;
        });
    });
    return createScene();
};
View source · gameobjects/polygon/create_polygon.ts:98

createShapesfunctionnacatamalon

createShapes(options: TShapesOptions) => TShapes

Puts shapes in the scene, drawn by the graphics card as they are each frame: rectangles, with rounded corners or not, circles, ellipses and slices of them, outlines of any number of corners (hollowed in too, a star or a letter), and lines as wide as asked for. Each is filled, outlined, or both, in any colour, and they are all drawn together, in the order of the list.

  • rect: x, y (its top-left), width, height; radius rounds its corners (one, or one each from the top-left round), rotation turns it about its middle.
  • circle: x, y (its middle), radius; with start and end, in radians clockwise from the right, a slice: filled, a pie (a cooldown); outlined, the arc alone (a ring that fills up).
  • ellipse: as a circle, with radiusX, radiusY and rotation.
  • polygon: points, three or more round it.
  • line: points, two or more; closed joins the last to the first.
  • fill: a colour. stroke: { width, color }, with join ('miter', 'round', 'bevel'), cap for the ends of what is open ('butt', 'round', 'square'), and align for what is closed ('center', 'inside', 'outside').

They are plain data on what comes back, shapes: change a number (a bar's width, a slice's end), push one, take one out, and the next frame draws it. Their places are measured from the object's transform, which moves, turns and scales them all.

The pointer touches them as one thing, wherever one of them is drawn, filled or outlined: listen(hud, { onClick }), a drag or a drop zone, as on a sprite. What a listener is told names the whole set, not the shape under the pointer.

Their edges are hard, as everything the engine draws, and widths are in the game's pixels, so they grow with the camera's zoom. However many there are, the card draws them in one go: what they cost is working their corners out again each frame.

Parameters

optionsTShapesOptions

The shapes, their place and their look: see TShapesOptions.

Example

export const Level: TSceneFn = () => {
    let life = 1;
    let cooldown = 0;
    const hud = createShapes({
        transform: { x: 8, y: 8 },
        shapes: [
            { type: 'rect', x: 0, y: 0, width: 60, height: 6, radius: 2, fill: '#e15554' },
            { type: 'rect', x: 0, y: 0, width: 60, height: 6, radius: 2, stroke: { width: 1, color: '#ffffff', align: 'outside' } },
            { type: 'circle', x: 80, y: 3, radius: 6, start: -Math.PI / 2, end: -Math.PI / 2, fill: '#ffd23f' },
        ],
    });
    const bar = hud.shapes[0] as TShapeRect;
    const pie = hud.shapes[2] as TShapeCircle;

    useUpdate((delta) => {
        cooldown = Math.min(1, cooldown + delta / 3);
        bar.width = 60 * life;
        pie.end = -Math.PI / 2 + cooldown * Math.PI * 2;
    });
    return createScene();
};
View source · gameobjects/shapes/create_shapes.ts:99

createSpriteTexturefunctionnacatamalon

createSpriteTexture(options: TSpriteTextureOptions, component?: (args: TArgs) => unknown, args: TArgs) => TTexture

Makes a picture and fills it with a component: whatever component draws, and whatever it creates with useSpawn, ends up in the picture instead of on the screen, every frame. A model then shows the picture the way it shows any image, so the 2D moves with the model and is seen in its perspective: a handheld's screen, a monitor, a sign.

The component is a full part of the scene: it updates, it runs its scripts, it pauses with the scene and destroy takes it away. What it draws is measured in the picture's pixels, from its top-left corner, the way a scene without a camera is. A camera it asks for is the picture's own and leaves the scene's alone, and a lamp it holds lights only the picture.

With sees: '3d' the picture also shows the models of the world around it, from the component's own 3D camera: a security camera, and the monitor is whatever shows the picture.

With sees: 'world' it is a view of the whole world of its scene, through the component's own cameras: a minimap, a mirror, half of a split screen. See TSpriteTextureOptions.sees, and viewToWorld for clicks on it.

Whatever you pass after the component reaches it as its arguments, as with useSpawn.

Parameters

optionsTSpriteTextureOptions

How big the picture is, what is behind it, what it sees and, for a view of the world, what of it.

componentoptional(args: TArgs) => unknown

What is drawn into it. Left out, the picture shows only its background, or the scene when it sees it.

argsTArgs

What component is called with, the way a maker from useSpawn passes them on.

Example

const Screen = () => {
    const pet = createSprite({ key: 'pet', transform: { x: 40, y: 40 } });
    useUpdate((delta) => {
        pet.transform.x += delta * 10;
    });
};

const Level = () => {
    useCamera3d({ projection: 'perspective', transform: { z: 3 } });
    const screen = createSpriteTexture({ width: 128, height: 128 }, Screen);
    createMesh({ geometry: useCubeGeometry(), texture: screen });
    return createScene();
};
View source · gameobjects/sprite_texture/create_sprite_texture.ts:314

createTextfunctionnacatamalon

createText(options: TTextOptions) => TText

Writes something on screen with a bitmap font: a score, a title, a menu, "PRESS START".

You get the text back and change it by changing its fields: score.text = 'SCORE ' + points shows on the next frame. It draws nothing until its font has loaded, and appears on its own then.

The font is optional: left out, the text uses the one the engine carries (Nacatamal Arcade, 8 px, with lowercase, accents and ñ), which is there from the start. Two more are always there too, named by key: font: 'nacatamalon:square' (the same weight, square corners) and font: 'nacatamalon:thin' (one-pixel strokes, narrower). Pass font from useLoadFont (a .ttf or .woff) or useLoadBitmapFont for a font of your own, or the key one was loaded under, by this scene or an earlier one: a loading scene can load every font once and the rest of the game name them, font: 'title'.

  • style.fontSize is how tall a line is, in pixels. A pixel font looks crisp at whole multiples of its own height and uneven in between; the console says so if that happens.
  • \n starts a new line, and style.maxWidth breaks one that runs wider at a space, so a dialogue box needs no \n put in by hand. style.align lines them up.
  • x and y are the top-left corner of the text unless anchor says otherwise: { x: 0.5, y: 0 } centres a title on x.
  • A lowercase letter the font does not have is drawn as its capital, since most arcade fonts only have capitals.

It moves with the camera and obeys zIndex and useScreenSpace like a sprite, and takes the same pointer events (onClick, onPointerOver...), which fire anywhere inside the block.

Parameters

optionsTTextOptions

What it says, how it looks, and optionally with which font.

Example

export const Level: TSceneFn = () => {
    // No font given: the engine's own.
    const score = createText({ text: 'SCORE 0', style: { fontSize: 16 }, transform: { x: 8, y: 8 } });
    // A font of your own, loaded from its two files.
    const font = useLoadBitmapFont({ json: '/fonts/arcade/arcade.json', atlas: '/fonts/arcade/arcade.png' });
    createText({ text: 'HI SCORE', font, transform: { x: 8, y: 28 } });
    // A font an earlier scene loaded with useLoadFont({ src, key: 'title' }), by its key alone.
    createText({ text: 'LEVEL 1', font: 'title', transform: { x: 8, y: 48 } });
    let points = 0;

    useUpdate(() => {
        points += 1;
        score.text = 'SCORE ' + points;
    });

    return createScene();
};
View source · gameobjects/text/create_text.ts:90

createViewfunctionnacatamalon

createView(options: TViewOptions, component?: (args: TArgs) => unknown, args: TArgs) => TSprite

A view of the world in a rectangle of the screen: half of a split screen, a minimap in a corner, a rear-view mirror.

The short way to write what createSpriteTexture({ sees: 'world' }) does with a sprite pinned to the screen showing it: component asks for the view's cameras and draws what only the view shows, exactly as there. For a view that is round, carries a material or sits on something that moves, make the picture and show it yourself.

It does not take the world off the screen: a split screen, where the halves cover it, says so with useWorldOffScreen, and a minimap over the game does not.

Whatever you pass after the component reaches it as its arguments, as with useSpawn.

Parameters

optionsTViewOptions

Where on the screen it goes and how big it is, what is behind it, and what of the world it takes in.

componentoptional(args: TArgs) => unknown

What the view looks through and draws on top: its useCamera2d, useCamera3d or useCameraFollow, and a marker. Left out, it looks through the scene's cameras.

argsTArgs

What component is called with, the way a maker from useSpawn passes them on.

Example

const Half = (player: TSprite) => {
    useCamera2d();
    useCameraFollow(player);
};

const Level = () => {
    useWorldOffScreen();
    const p1 = createSprite({ key: 'hero', transform: { x: 40, y: 200 } });
    const p2 = createSprite({ key: 'hero', transform: { x: 120, y: 200 } });
    createView({ x: 0, y: 0, width: 240, height: 270 }, Half, p1);
    createView({ x: 240, y: 0, width: 240, height: 270 }, Half, p2);
    return createScene();
};
View source · gameobjects/sprite_texture/create_view.ts:55

destroyfunctionnacatamalon

destroy(target: TDrawable | TGameObject | TModel, options?: TDestroyOptions) => void

Removes something from the game for good: a sprite, or a whole thing made by a spawner, with its sprites, its per-frame code and its cleanups. It stops being drawn in this same frame, whether it goes at once or at the end of it, and a spawned object stops running the moment you say so.

Destroying twice, or destroying something that was never on screen, does nothing and says nothing: you should not have to find out whether someone else got there first. What is destroyed is gone, not recycled, so keep making new ones rather than reviving old ones.

A sprite of something spawned goes alone: the thing it belongs to stays, with its other sprites and its useUpdate. destroy(ownerOf(sprite)) takes the whole thing.

Images are not freed. Several things can be showing the same one, and the game keeps it for whoever asks next, so destroying a sprite never costs the next one a reload.

Parameters

targetTDrawable | TGameObject | TModel

The sprite, model or spawned object to remove. A scene is not one of these: it leaves through useScene().stop(), and passing one here warns and does nothing.

optionsoptionalTDestroyOptions

See TDestroyOptions. Leave it out for the usual behaviour.

Example

export const Level: TSceneFn = () => {
    const bullet = createSprite({ key: 'bullet', transform: { x: 160, y: 200 } });

    useUpdate((delta) => {
        bullet.transform.y -= 300 * delta;
        if (bullet.transform.y < 0) {
            destroy(bullet);
        }
    });

    return createScene();
};
View source · destroy/destroy.ts:82

emitParticlesfunctionnacatamalon

emitParticles(emitter: TParticles | TParticles3d, count: number) => void

Asks for count particles to appear, over and above whatever the effect does by itself.

What a game calls when something happens: a hit, a footstep, a jump. It works on an emitter that is switched off, which is the usual way a one-shot is used.

They appear on the next step rather than inside this call, and that is deliberate: a particle is born where its emitter ends up, and that is not known until the tree has been walked later in the same frame. So this works even for the ordinary pattern of moving the emitter and firing it in the same breath, which is exactly where doing it on the spot would use the place it was before.

Parameters

emitterTParticles | TParticles3d

The emitter, as createParticles or createParticles3d gave it back.

countnumber

How many to make now.

Example

const pointer = usePointer();
declare const sparks: TParticles;

pointer.onDown((info) => {
    sparks.transform.x = info.worldX;
    sparks.transform.y = info.worldY;
    emitParticles(sparks, 40);
});
View source · gameobjects/particles/verbs.ts:123

findObjectfunctionnacatamalon

findObject(root: TBox, name: string) => TBox | null

The first thing called name inside root, looking at root itself first and then down through everything in it, or null when there is none.

What a behaviour uses to reach a named part of what it is attached to: the turret of a tank, the hand a sword goes in, the door that has to slide. null is an ordinary answer and has to be handled, because a part can be renamed while the game runs, or come in with another name when a model is exported again. Nothing here throws.

Something destroyed is not found, nor anything inside it, even before the end of the frame takes it out: a coin collected this frame is not there to be collected again. To look across the whole scene rather than inside one thing, start from sceneOf(self).

By name and not by id, because a name is what an author can type.

Parameters

rootTBox

Where to look.

namestring

The name to find.

Example

registerScript('turret', (self) => {
    const place = findObject(self, 'Barrel')?.transform;
    if (place === undefined || place === null) return;
    useUpdate((delta) => { place.rotationY += delta; });
});
View source · box/find_object.ts:36

findObjectsfunctionnacatamalon

findObjects(root: TBox, name: string) => TBox[]

Everything called name inside root, root included, in the order findObject would meet them. For names shared on purpose: the four wheels of a car, every spawn point of a level.

An empty list rather than null when nothing matches, so a for ... of over it needs no guard. Leaves out what is destroyed, as findObject does.

Parameters

rootTBox

Where to look.

namestring

The name to find.

View source · box/find_object.ts:68

ownerOffunctionnacatamalon

ownerOf(drawable: TDrawable) => TGameObject | null

The object a sprite, a text or a mesh belongs to: the thing useSpawn made that drew it, or the scene for one made straight in the scene's body. null once it or its piece has been destroyed, or for one that was never placed.

The way back from what was touched to the whole piece: destroy(sprite) takes only that sprite away and leaves its piece running, with its other sprites and its useUpdate; destroy(ownerOf( sprite)) takes the piece. And ownerOf(sprite).api is what the piece offers.

Parameters

drawableTDrawable

Something drawn.

Example

usePointer().onDown(({ target }) => {
    const piece = target === null ? null : ownerOf(target);
    if (piece !== null && piece !== sceneOf(piece)) destroy(piece);
});
View source · box/owner_of.ts:29

pauseParticlesfunctionnacatamalon

pauseParticles(emitter: TParticles | TParticles3d, paused: boolean) => void

Freezes it, or lets it go again.

Nothing moves and nothing is born, and it keeps drawing exactly what it last drew. Freezing rather than hiding, because the useful half of this is being able to look at it: a still flame is something you can line something else up against, and a hidden one is a hole where you have to remember an effect was.

Parameters

emitterTParticles | TParticles3d

The emitter, as createParticles or createParticles3d gave it back.

pausedboolean

true to freeze it, false to let it go again.

View source · gameobjects/particles/verbs.ts:58

playParticlesfunctionnacatamalon

playParticles(emitter: TParticles | TParticles3d) => void

Starts the effect from the beginning: new particles appear, and a burst fires again.

The cycle is put back to exactly zero, and that is what re-arms a burst: a one-shot that has already gone off is a one-shot that can be fired again.

Parameters

emitterTParticles | TParticles3d

The emitter, as createParticles or createParticles3d gave it back.

View source · gameobjects/particles/verbs.ts:17

resizeSpriteTexturefunctionnacatamalon

resizeSpriteTexture(picture: TTexture, width: number, height: number) => void

Makes a picture from createSpriteTexture another size: half of a split screen when the window grows, a monitor that opens wider. It stays the same picture, so whatever shows it goes on showing it; only the texture on the graphics card behind it is made again, and the old one let go of. A view sees more or less of the world, as the screen does when the game is resized.

Parameters

pictureTTexture

The picture, as createSpriteTexture gave it back.

widthnumber

In pixels, rounded down and at least 1.

heightnumber

In pixels, rounded down and at least 1.

Example

declare const left: TTexture;
declare const right: TTexture;
useGame().onResized(({ width, height }) => {
    resizeSpriteTexture(left, width / 2, height);
    resizeSpriteTexture(right, width / 2, height);
});
View source · gameobjects/sprite_texture/create_sprite_texture.ts:222

sceneOffunctionnacatamalon

sceneOf(object: TBox) => TGameObject

The scene something is in: the top of its tree, the scene itself for a scene.

What a behaviour starts from to reach the rest of its scene by name: findObject(sceneOf(self), 'Score') finds the score wherever it sits, not only among the behaviour's own children. A box in a screen inside the game (createSpriteTexture) is still in the scene that screen is in.

Parameters

objectTBox

Anything in a scene: a box, a component, a scene.

Example

registerScript('door', (self) => {
    useReady(() => {
        const exit = findObject(sceneOf(self), 'Exit');
        if (exit !== null) exit.visible = false;
    });
});
View source · box/scene_of.ts:29

setViewFilterfunctionnacatamalon

setViewFilter(picture: TTexture, filter: { hide, only }) => void

Changes what a view of the world (createSpriteTexture({ sees: 'world' })) takes in, while the game runs: a minimap that starts showing the rooms already visited, a mirror that stops showing the player's own car. What is given replaces what it had; null or left out, none.

Parameters

pictureTTexture

The view, as createSpriteTexture gave it back.

filter{ hide, only }

What it leaves out (hide) and what alone it takes in (only). hide wins.

Example

declare const minimap: TTexture;
setViewFilter(minimap, { hide: { tags: ['secret'] } });
View source · gameobjects/sprite_texture/create_sprite_texture.ts:189

stopParticlesfunctionnacatamalon

stopParticles(emitter: TParticles | TParticles3d) => void

Stops new ones appearing.

Not the same as clearing. Whatever is already in the air goes on living, moving and drawing until its own time runs out, which is what putting a torch out looks like. Use clearParticles for the other thing.

Parameters

emitterTParticles | TParticles3d

The emitter, as createParticles or createParticles3d gave it back.

View source · gameobjects/particles/verbs.ts:39

transformForwardfunctionnacatamalon

transformForward(transform: TTransform3d) => { x, y, z }

Which way something is facing.

Forward is -Z, which is the convention every model format and every camera in this engine already uses: a camera at the origin looks that way, and a model exported facing the viewer faces that way. A light shines along it, so a light is aimed by turning it, exactly like a camera.

A quaternion, when the transform has one, decides the answer, as it decides the turn everywhere else. The lights and cameras of a frame pass theirs as null on purpose and are aimed by their angles. What comes back is always one unit long, and the roll never changes it.

Parameters

transformTTransform3d

Where something is and how it is turned.

View source · render/shared/transform_basis.ts:21

useSelffunctionhooknacatamalon

useSelf() => TGameObject

The thing being built right now, so it can refer to itself later: almost always to end its own life once it has done its job.

Inside a component made by a spawner, this is that one thing. Inside a scene body it is the scene, which cannot be destroyed this way: a scene leaves through useScene().stop().

Call it while the thing is being built, like every hook, and keep what it returns.

Example

const Spark = () => {
    const self = useSelf();
    let left = 0.4;

    useUpdate((delta) => {
        left -= delta;
        if (left <= 0) {
            destroy(self);
        }
    });
};
View source · hooks/spawn/use_self.ts:35

useSpawnfunctionhooknacatamalon

useSpawn(component: (args: TArgs) => TApi, given: string | TSpawnOptions) => (args: TArgs) => TGameObject<TApi>

Prepares a maker for component, so the scene can create as many of them as it likes, whenever it likes: while it is being built, from a frame, from a timer, from a click.

This is what gives each one a life of its own. Calling Bullet(10) yourself is an ordinary function call, and the useUpdate inside it belongs to whoever called it, mixed in with everything else there. Made through the maker, each bullet gets its own place: its sprites, its per-frame code and its cleanups are its, and destroy can take exactly one of them away.

Whatever you pass to the maker reaches the component as its arguments: one object of props, makeBullet({ x: 10 }), reads like the tag it stands for and keeps its names. They arrive once, when the thing is made; the component is not run again when they change. What comes back is the thing itself, for later: keep it to destroy it, or let the component end its own life with useSelf.

What is the same for every one goes to useSpawn, what changes from one to the next to the maker: the name and the place are decided once, here, while the scene is built; the props are given to each one, whenever it is made. Two buttons of one component with names of their own are two makers, which cost nothing.

Whatever the component returns is the thing's api, so the one who made it can talk to it: an enemy that returns { hurt } is hurt with enemy.api.hurt(1), typed, with no signal and no lookup. It is there once the maker returns, never while the component is still being run.

Call useSpawn while the scene is being built, like every hook, and the maker whenever: from useUpdate, a timer or a listener, which is how things are made while the game runs. It remembers the scene it was called in, so the maker keeps working for as long as that scene runs. Called once the scene has stopped (from a setTimeout or a listener that outlived it), it makes nothing, says so once, and gives back something already destroyed; under something destroyed, the same in silence.

Parameters

component(args: TArgs) => TApi

The function describing one of these things. Whatever it returns becomes the new thing's api.

givenstring | TSpawnOptions

Example

// An enemy that its level can hurt.
const Bat = ({ x }: { x: number }) => {
    const self = useSelf();
    let life = 3;
    createSprite({ key: 'bat', transform: { x, y: 120 } });
    return {
        hurt: (damage: number) => {
            life -= damage;
            if (life <= 0) destroy(self);
        },
    };
};

export const Cave: TSceneFn = () => {
    const bat = useSpawn(Bat, 'Bat')({ x: 200 });
    const keys = useKeyboard();

    useUpdate(() => {
        if (keys.justPressed('x')) bat.api.hurt(1);
    });

    return createScene();
};

Example

declare const gun: TSprite;
declare let firing: boolean;

const Bullet = ({ x }: { x: number }) => {
    const self = useSelf();
    const sprite = createSprite({ key: 'bullet', transform: { x, y: 200 } });

    useUpdate((delta) => {
        sprite.transform.y -= 300 * delta;
        if (sprite.transform.y < 0) {
            destroy(self);
        }
    });
};

export const Level: TSceneFn = () => {
    // Shots leave the gun behind, so they hang from the scene.
    const spawnBullet = useSpawn(Bullet, { name: 'Bullet', parent: 'scene' });

    useUpdate(() => {
        if (firing) spawnBullet({ x: gun.transform.x });
    });

    return createScene();
};
View source · hooks/spawn/use_spawn.ts:149

useTransformfunctionhooknacatamalon

useTransform(options: TTransformOptions) => TTransform3d

Gives this object a place of its own, and moves everything inside it.

Without it, each sprite, text or model carries its own position and they are moved one by one. With it, they are placed once, relative to the object, and moving the object moves all of them together: a turret and its barrel, a card and its number, a ship and everything bolted to it. Anything made inside this one is placed relative to it too, however deep it goes.

What comes back is the placement itself, so changing it is all it takes and it takes effect on the next frame drawn. rotation turns it in the plane, which is the only one a 2D game needs; rotationX and rotationY are for three dimensions.

For something free to point anywhere there is quaternion, and setting one puts the three angles aside: quatFromEuler starts one off facing the same way they did, and quatMultiply turns it on from there (by a quatFromAxisAngle). Note that it speaks for three dimensions only: pictures and writing inside this one are still turned by rotation.

Asking twice gives back the same placement, so a later call never quietly throws away where something already was.

Parameters

optionsTTransformOptions

Where to start. Anything left out starts at the origin, unturned and unscaled.

Example

const Turret = (x: number) => {
    const place = useTransform({ x, y: 200 });

    // Both are placed relative to the turret, so turning it turns them together.
    createSprite({ key: 'base', transform: { x: 0, y: 0 } });
    createSprite({ key: 'barrel', transform: { x: 0, y: -12 } });

    useUpdate((delta) => {
        place.rotation += delta;
    });
};
View source · hooks/transform/use_transform.ts:61

viewToRayfunctionnacatamalon

viewToRay(sprite: TSprite, point: TViewPointInput) => TViewRay

The ray of a view's 3D camera through a point on the sprite showing the view: what a click on it picks among the models it sees. Test it against what can be picked, or against the floor's plane, as with screenToRay, which this is for a view.

A view sees through its own 3D camera, or the scene's when it asked for none; one that follows the 2D camera (follow2d) follows the view's.

Parameters

spriteTSprite

The sprite showing the view.

pointTViewPointInput

The point on it, or the pointer's info.

Example

declare const shown: TSprite;
usePointer().onDown((info) => {
    const ray = viewToRay(shown, info);
    if (ray.inside && ray.direction.y < 0) {
        const t = -ray.origin.y / ray.direction.y;
        const floor = { x: ray.origin.x + ray.direction.x * t, z: ray.origin.z + ray.direction.z * t };
    }
});
View source · gameobjects/sprite_texture/view_coordinates.ts:335

viewToWorldfunctionnacatamalon

viewToWorld(sprite: TSprite, point: TViewPointInput) => TViewToWorld

Turns a point on the sprite that shows a view into the point of the world the view sees there: clicking on a minimap to go where was clicked, aiming through a scope.

The view is a picture from createSpriteTexture({ sees: 'world' }) and this is the sprite showing it, wherever it is and however it is placed: grown, turned, mirrored, held by any point, under anything that moves it, showing a frame of the picture or repeating it. The point is in the sprite's place, the world of its scene or the screen's pixels for a sprite pinned to the screen; the pointer's info can be handed over as it is, and the right one is taken from it.

What comes back is in the view's 2D world. A view's 3D camera sees through a point along a whole line rather than at one place: viewToRay gives that line. On a picture that sees only a world of its own ('inside'), the point is in that world.

Parameters

spriteTSprite

The sprite showing the view.

pointTViewPointInput

The point on it, or the pointer's info.

Example

declare const shown: TSprite;
declare const player: TSprite;
usePointer().onDown((info) => {
    const at = viewToWorld(shown, info);
    if (at.inside) {
        player.transform.x = at.x;
        player.transform.y = at.y;
    }
});
View source · gameobjects/sprite_texture/view_coordinates.ts:254

worldToViewfunctionnacatamalon

worldToView(sprite: TSprite, point: { x, y }) => TWorldToView

Turns a point of the world a view sees into where it lands on the sprite showing the view: a marker over the minimap, or an arrow at its edge for what is off it.

Never empty-handed: a point the view does not take in still lands somewhere past the sprite, and edge is where the sprite's edge is in that direction, seen from its middle.

Parameters

spriteTSprite

The sprite showing the view.

point{ x, y }

A point of the view's 2D world.

Example

declare const shown: TSprite;
declare const enemy: TSprite;
declare const arrow: TSprite;
useUpdate(() => {
    const at = worldToView(shown, enemy.transform);
    arrow.visible = !at.inside;
    arrow.transform.x = at.edge.x;
    arrow.transform.y = at.edge.y;
});
View source · gameobjects/sprite_texture/view_coordinates.ts:289

T2dOptionstypenacatamalon

T2dOptions: { transform, anchor, pivot, tint, visible, zIndex, smooth, parallax, blend, tags, material, uniforms } & TSpriteEvents

What the flat pictures share, a sprite, a text and a panel: a rectangle placed by its anchor, turned about its pivot, touched by the pointer. Each adds what is its own (a picture, the words, the borders); these mean the same on all three.

Not everything drawn flat: a polygon, a tilemap and particles have options of their own, and something new that is not one of these pictures does not have to fit it. T3dOptions is the same for the lit models.

Properties

transformoptionalPartial<TTransform2d>

Where it is, how it is turned and how big. Only what is given: the rest is no turn and a scale of 1, so { x, y } is enough. Copied, so the object handed in stays the caller's.

anchoroptional{ x, y }

Which point of it sits on its transform, in 0-1 of its own size: { x: 0.5, y: 0.5 } is its middle, { x: 0.5, y: 1 } the middle of its bottom edge (a character standing on a floor), { x: 0, y: 0 } its top-left corner. Rotation and scale happen around it, unless pivot says another point. Default: the middle for a sprite and a panel, the top-left corner for a text.

They differ on purpose. A thing of the world sits by its middle, the point it turns and grows on; a text sits by its corner so it grows without moving, and a score going from 9 to 10 does not shift. A label centred on a panel gives them both the same anchor.

pivotoptional{ x, y }

The point it turns and grows about, in 0-1 of its own size, when it is not the anchor: the anchor decides where it sits, the pivot what it spins on. A door anchored at its corner turns on its hinge ({ x: 0, y: 0.5 }); a score anchored at its left edge pops bigger from its middle ({ x: 0.5, y: 0.5 }). Default: its anchor.

tintoptionalTColorOption

Its colour, multiplied over what it draws: '#ff6b1a', 0xff6b1a, 'tomato' or a TColor. Default white, drawn as it is. A TColor is copied, so changing this one's tint changes no other thing given the same colour.

visibleoptionalboolean

Whether it is drawn. Default true. false makes it hidden from the start, which is how a set of them is prepared in advance and shown one at a time.

zIndexoptionalnumber

Which others it is drawn in front of, within its own scene: higher numbers go on top, and negatives are allowed. The same number keeps the order they were made in. Default 0. It can be changed at any time and takes effect on the next frame drawn.

smoothoptionalboolean

Crisp (false) or blended (true) when scaled: false keeps pixel art crisp. Default: the game's smooth.

parallaxoptional{ x, y }

How much it moves with the camera: 1 (the default) as everything else, 0 not at all, and in between further away: { x: 0.3, y: 0 } is a far range of mountains that slides slowly by and keeps its height. Only how it is drawn and touched by the pointer: its placement stays what it says. Something pinned to the screen (useScreenSpace, a HUD) does not see the camera, so it has no parallax whatever this says.

blendoptional'alpha' | 'additive'

How it lands on what is behind it. 'alpha' (the default) covers it as far as its alpha says. 'additive' adds its colour instead, so it can only brighten: a halo, a flash, a glowing "LEVEL UP!", a lamp at night. Two additive things over each other are brighter than one. Can be changed any frame.

tagsoptionalstring[]

What it is, as useTag says it: ['wall']. The same as adding them after.

materialoptionalTSpriteMaterial

An effect of its own, from createMaterial. Omitted is the built-in shader.

uniformsoptionalTUniformValues

Its own values for that material's uniforms, laid over the material's own.

onPointerOveroptionalTPointerListener

The pointer comes over the sprite.

onPointerOutoptionalTPointerListener

The pointer stops being over it, or leaves the game.

onPointerMoveoptionalTPointerListener

The pointer moves while over it.

onPointerDownoptionalTPointerListener

A button is pressed, or a finger touches, over it.

onPointerUpoptionalTPointerListener

A button is released, or a finger lifts, over it.

onClickoptionalTPointerListener

Pressed and released without leaving it. The cursor turns into a hand over it.

onDragStartoptionalTPointerDragListener

Pressed with the main button (or a finger) and moved far enough not to be a click: a few pixels of the page, more for a finger, which shakes. Once it starts, the press is a drag and not a click: letting go over it does not call onClick. The cursor turns into an open hand over something that can be dragged, and a closed one while it is.

Nothing moves by itself: the events say what the pointer did, and the game decides what that does (follow it, pull a slingshot back, turn a dial). useDraggable is the one that moves it.

onDragoptionalTPointerDragListener

The pointer that started the drag moved, wherever it is: over the sprite or not, in the game or off its edge. Called right after onDragStart too, so the first move is not lost.

onDragEndoptionalTPointerDragListener

The pointer that dragged it let go, with target and hits saying what it was let go over.

View source · gameobjects/types/t_2d_options.ts:19

T3dOptionstypenacatamalon

T3dOptions: TMeshSurfaceOptions & { transform, zIndex, visible, castShadow, alwaysDrawn, boundsMargin }

What the lit models share, a shape made with createMesh and a model placed from a file with createModel: where it is, how it is drawn and how its surface is painted. Each adds what is its own (the shape and its material; the file and its looks).

The 3D side of T2dOptions, and as narrow: only the lit models use it. What else is drawn in three dimensions (particles, lines) has options of its own, and something new that is not a lit model does not have to fit it.

Properties

transformoptionalPartial<TTransform3d>

Where it is. Anything left out is at the origin, unturned and unscaled.

zIndexoptionalnumber

Draw order within its scene. Default 0, and on a tie a model goes under a sprite.

visibleoptionalboolean

Whether it is drawn. Default true.

castShadowoptionalboolean

Whether it is drawn into the shadow map. Default true.

false is for the things a shadow of would be wrong rather than expensive: the ground the shadows land on, a decal, a pane of glass, the soft disc of a blob shadow. None of it costs anything unless some light in the scene asked to cast in the first place.

There is no matching receiveShadow. Everything drawn in three dimensions receives, including a model wearing a shader you wrote yourself, because a surface that silently stopped taking shadows the moment you gave it an effect is a surprise with nothing to explain it.

alwaysDrawnoptionalboolean

Drawn even when nothing of it is on screen. Default false: a model whose box is wholly outside what the camera sees is skipped that frame, which is what keeps a big world cheap.

For when that box lies and you would rather not say by how much: something a shader of yours throws far from where it was made. boundsMargin says by how much instead, and keeps the saving.

boundsMarginoptionalnumber

How far past its own shape it can reach, in its own units: the height a wave of a vertex shader lifts it, an arm stretched further than any of its movements does. Its box grows by that much on every side before it is judged on or off screen.

A material that moves its corners in its shader cannot be measured from here, so a model wearing one is never skipped until this says how far they go. Bones are measured already: a model that bends is judged in the pose it is in.

tintoptionalTColorOption

Multiplies its colour: its picture's, or the colours a model's file gave each piece, so they are kept and shaded. White, the default, leaves it as it is. Any colour: '#c08040', 0xc08040.

alphaoptionalnumber

How solid it is, 0 to 1. Default 1.

transparentoptionalboolean

Drawn as see-through even at full alpha: for a shader that works out its own alpha, or a picture with see-through parts. Omitted, it is see-through when alpha or its tint's own is below 1, or when a model's file says a piece is (alphaMode: 'BLEND'). A see-through model is drawn after the solid ones, furthest first, and hides nothing.

blendoptional'alpha' | 'additive'

How it lands on what is behind it. 'alpha' (the default) covers it as far as its alpha says. 'additive' adds its colour instead, so it can only brighten: a flash, a hologram, a shield, a beam of light, a magic circle. Its alpha says how much of it is added. An additive model is always drawn as see-through (after the solid ones, hiding nothing, whatever transparent says), casts no shadow, since light added blocks none, and fades into the fog by adding less rather than by turning the fog's colour.

specularoptionalTColorOption

The colour of its shine. Default none, which is a matt surface: a shine is the thing that makes something read as wet, polished or metal, and everything else looks better without it.

shininessoptionalnumber

How tight that shine is. Default 32. Higher is smaller and harder.

vertexSnapoptionalboolean | number

Its corners land on a coarse grid of the screen, the way the PlayStation drew them: a model shivers as it moves and its edges crawl as the camera turns. A number is how many rows the grid has (120 is the classic look, smaller is wilder); true uses the game's own rows, which is subtle. Left out, the scene's render style decides (useRenderStyle), and with none it is off; false, or 0, says no to that style.

affineoptionalboolean

Its picture is stretched straight across the screen without correcting for depth, the way the PlayStation drew it: big flat surfaces bend and swim as the camera comes close. Left out, the scene's render style decides (useRenderStyle), and with none it is off; false says no to it.

perPixeloptionalboolean

Its light is worked out at every pixel rather than at its corners: a shine is a round, clean spot that slides across the surface however few triangles the model has, the look of the computer graphics of the era (glossy plastic, chrome). It costs more per pixel. Left out, the scene's render style decides (useRenderStyle), and with none it is off; false says no to it.

reflectionoptionalTTexture | TMaterialReflection

What its surface reflects: a round picture of its surroundings, and how much in front and at the edge (see TMaterialReflection). The picture alone is a glossy plastic; front: 0.9 is chrome. Default none.

normalMapoptionalTTexture | TMaterialNormalMap

A normal map that bends its surface at every pixel: the picture, or { texture, strength }. See the material's normalMap.

uvTransformoptionalTMaterialUvTransform

Its picture laid moved from where its shape puts it: repeated, turned and slid, { scale, rotation, offset }. See the material's uvTransform. A model file's own is read from the file, and this one is laid in its place.

culloptionalTCullMode

Which side of its triangles is thrown away. 'back' (the default) is a shape seen from outside; 'front' one seen from inside, such as a dome of sky; 'none' draws both sides, each lit as the side it is, for a leaf, a sheet or the top of a liquid.

alphaCutoffoptionalnumber

Cuts its picture out instead of blending it: a pixel whose alpha is below this number is not drawn, every other one is drawn solid. For a fence, a leaf, grass or a paper figure, which then hides what is behind it and casts the shadow of its shape. 0.5 is the usual; from 0 to 1. Omitted, nothing is cut (a model file's MASK pieces bring their own).

smoothoptionalboolean

Overrides the game's smooth for this model alone.

wrapoptionalTTextureWrap | { u, v }

What its picture does past its edge. Default 'repeat', or what a model's file asked for each piece, which is almost always to repeat.

View source · gameobjects/types/t_3d_options.ts:124

TCullModetypenacatamalon

TCullMode: 'back' | 'front' | 'none'

Which side of each triangle is thrown away, by which way it faces the camera.

  • 'back': the side facing away. A closed shape seen from outside, which is nearly everything, and half the work saved, since half of a closed shape always faces away.
  • 'front': the side facing the camera. A shape seen from inside: a dome of sky, a room the camera stands in. It is lit from inside too.
  • 'none': nothing. Both sides drawn, each lit as the side it is: a leaf, a sheet, a flag, the top of a liquid.
View source · materials/types/t_material.ts:110

TDestroyOptionstypenacatamalon

How destroy should go about it.

Properties

immediateoptionalboolean

Ask for it to be gone the instant you say so, instead of at the end of the frame. It is a request and not an order: asked for while the game is running its updates, it is queued anyway, so the call is never the wrong one to write.

View source · destroy/destroy.ts:19

TDrawabletypenacatamalon

TDrawable: TSprite | TText | TNineSlice | TTilemapLayer | TMesh | TParticles | TParticles3d | TLines | TPolygon | TShapes | TCustomDrawable

Anything drawn in a scene: a sprite, a text, a nine-slice, a map layer, a shape, shapes, a model, particles, lines, or a drawing of a kind a plugin registered. It grows by adding members (TSprite | TText | TTilemap), and every member carries a type, so a switch on it knows which one it holds.

A union and not a shared base type: a base would need a cast to reach any field of its own, and could never tell a backend that it forgot a kind.

View source · gameobjects/types/t_drawable.ts:24

TGameObjecttypenacatamalon

TGameObject: TBox & { api }

One thing made by a spawner: what destroy takes to remove it whole, with its sprites, its per-frame code and its cleanups.

api is whatever its component gave back, typed: TGameObject<{ hurt(): void }> for an enemy whose component returns { hurt }. Left out, it is unknown, which every object is.

Properties

idstring

Unique for the life of the game.

namestring

What the box is called where it was placed. Not unique: two enemies can share it.

tagsstring[]

What it is: 'enemy', 'coin', 'damageable', as many as it likes. What useTag adds and finds, and what collisions are asked by. Changed whenever the game likes.

parentTBox | null

null for a scene root. Kept so a box can be detached without searching the tree.

childrenTBox[]
updateCallbacks(dt: number, time: number) => void[]

Registered by useUpdate, called every frame with the delta and the scene's time, in seconds.

lateCallbacks(dt: number, time: number) => void[]

Registered by useLateUpdate, called every frame once every updateCallbacks of the scene has run, with the same delta and time.

moveCallbacks(dt: number, time: number) => void[]

Registered by what moves a body against the world (a character body), called every frame once every updateCallbacks of the scene has run, where the game set its speed, and before hitboxes are compared and lateCallbacks run, with the same delta and time.

cleanups() => void[]

Run once, children first, when the box leaves the tree.

drawablesTDrawable[]

What this box draws: its own sprites, not other boxes. Read every frame to fill the frame context.

scriptsTScriptAttachment[]

The behaviours attached to it, in the order they were attached, which is the order they ran in. See useScript.

An attachment is kept whether or not the behaviour ran: a saved scene outlives the code it names, so a name nothing registered is reported and held rather than dropped, and saving again does not quietly delete somebody's work.

scriptApisMap<string, unknown>

What each behaviour on this object returned, by its name, and what they offered with provide, by its word: read by useScriptApi. Empty on almost every object.

Runtime only, and never written to a file: these are functions, and the scripts are run again when the scene is opened and return them again.

apiunknown

What its component gave back when useSpawn made it: usually a few functions for whoever made it to call, such as hurt. undefined for anything else, and for a component that gives back nothing.

Runtime only, and never written to a file, like scriptApis, and for the same reason: the component is run again when the scene is opened and gives it back again.

dataTDataRecord<unknown>[]

The state its own body asked for with useData, in the order it asked.

A port like the others, and the reason it is one rather than a closure variable: this is what gets written down when the scene is saved, and read back when it is opened. State nobody can see is state a level editor cannot show and a save file cannot keep.

The order is the identity, which is what makes it positional in the document too.

soundsTSoundAttachment | TMusicAttachment | TSongAttachment[]

The sounds attached to it: which clip, and how each was asked to play.

A port like the others, and for the same reason: a sound is something an object is (a torch crackles, a level has its music), so it has to be there to be shown in a list, edited and written down. What is kept is how it was asked to play and never what is playing, so a scene saved mid-tune comes back ready to start it rather than halfway through.

motionsTMotionAttachment[]

The motions it plays: which file, and how each was asked to play. Like a sound, never where it had got to.

storesstring[]

The stores this object uses, by name.

Names and nothing else, because a store is not in the object and cannot be: it outlives every scene, and one living here would die with its scene and be two the moment a second object named it. The link is what a behaviour follows to reach state it did not define, and it is what lets the tree answer which objects touch a given piece of state.

physicsTPhysicsBody | null

What this object is made of, physically, or null for one nothing can bump into.

A component and not a child object, because it is something the object is, the same as its picture and its sound. (An engine whose only primitive is the node has to make physics a node with a shape hanging under it; here there are both, and the rule for choosing is in the glossary.)

physicsWorldTPhysicsWorld | null

The simulation's settings, on a scene's root and nowhere else.

Gravity belongs to the scene rather than to anything in it: a scene seen from above has none and a platformer does. The root is an object like any other, so it needs no new home, and only the root's is read.

hitboxesTHitbox[]

The parts of it that can be touched, each on one side: useHitbox. Empty on almost every object. Runtime only for now.

pausedboolean

Only meaningful on a scene root: while true the tick skips this scene's updates and still draws it. Lives on the root so it goes away with the scene and cannot be left behind.

heldboolean

Only meaningful on a scene root: while true this scene is waiting behind a transition.

Held is not paused, and the difference is the drawing. A paused scene keeps being drawn, because that is what a pause menu over a frozen level needs. A held one is not drawn at all, because it is the scene coming in and the screen is still showing the one going out.

It does not update and does not answer the pointer either, and that matters as much as the drawing: a scene ticking away behind a cover arrives at its first visible frame already several frames old, with its character having walked on its own.

Set by useScene().change when it is given a transition, and cleared at the swap. Nothing else sets it: a scene cannot hold itself.

timenumber

Only meaningful on a scene root: the seconds of game time this scene has run, the time that useUpdate hands out. Advanced only when the scene's updates run, so a pause, a hold or a timeScale stop it exactly as they stop delta. On the root so a scene that starts again starts from zero. Runtime only.

loadsTLoadable[]

Only meaningful on a scene root: every asset the scene's body asked for, ready or not, in the order asked. What useLoadProgress() counts. Runtime only.

destroyedboolean

Set by destroy, on it or on an object above it, and never cleared. The frame that marked it stops updating it at once, even though it is only taken out of the tree at the end of that frame.

spawnedboolean

Born after its scene finished being built, rather than as part of building it.

The distinction is authored content against things in flight, and the place it matters is writing a scene down: a level built out of useSpawn calls in its own body is the level, and a bullet fired three seconds later is not. Saving a game mid-play must write the first and none of the second.

Worked out from whether a body was running at the moment of the spawn, not from which call made it. useSpawn is used for both jobs in the same file, so marking everything it makes would throw away the level along with the bullets.

camera2dTCamera2d | null

Only meaningful on a scene root: the camera the scene's 2D is drawn through, or null to draw it straight in screen pixels. On the root because a camera belongs to the scene, whichever object inside it asked for one.

camera3dTCamera3d | null

Only meaningful on a scene root: the camera the scene's 3D is seen through, or null to draw it flat on in the game's pixels. On the root for the same reason as the 2D one.

fogTFog | null

Only meaningful on a view (a scene root, or a box drawn into a picture): the fog its models are seen through, from useFog. Kept where the camera is, for the same reason.

renderStyleTRenderStyle | null

Only meaningful on a view, like fog: the style it is drawn in, from useRenderStyle, or null for the game's.

transformTTransform3d | null

Where this box is, which moves everything under it: its own drawables and every box beneath. null means it is not anywhere in particular, which is what an empty box used only to group things should cost: nothing.

This is what makes a box a place and not just a list. A turret's barrel, its flash and its shadow are put where the turret is, once, and turning the turret turns all three.

It reaches drawables and the lights beneath it. A camera reads its own placement instead, because a camera is what everything else is measured against.

lightsTLight[]

The lights this box gives off, in the order they were asked for: as many as it asks for, as a box carries as many pictures as it draws. A car's two headlights are two of them, each placed by its own transform.

Unlike a camera, a light moves with the box it is in, so a lantern carried by a character goes where the character goes without anything keeping the two in step.

particleColliderTParticleCollider2d | TParticleCollider3d | null

What this box is to particles: something solid, or null. One per box, like its light, and placed by the box the same way, so a step of a staircase is a box and its collider moves with it.

audioListenerTAudioListener | null

The ears of the game when they are on this object, or null. One per box. Without any, the game is heard from the camera.

spriteTextureTSpriteTexture | null

The picture this box and everything under it is drawn into instead of the screen, or null.

A box with one is where a world ends: the walk that draws the screen stops at it, a camera asked for under it is its own, and a lamp under it lights only the picture.

screenSpaceboolean

Pins this box, and everything under it, to the screen: drawn as if the scene had no camera. Inherited downwards, so marking a HUD once covers every piece of it however deep.

overlayboolean

Draws this box, and everything under it, over the screen effects (useOverlay). Inherited downwards. Set it with the hook, which is what tells the game to look for it.

unlit2dboolean

Leaves this box, and everything under it, out of the scene's 2D lights (useUnlit2d): drawn in its own colours where the world is dark, still moving with the camera. Inherited downwards.

worldOffScreenboolean

On a scene's top box: the screen draws only what is pinned to it (useScreenSpace), and the rest of the scene, its world, is seen only through views of it (createSpriteTexture({ sees: 'world' })). The scene runs as ever. Set by useWorldOffScreen.

maskTMask | null

The mask that keeps this box, and everything under it, to a rectangle or a shape, or null. Set by the mask's add (useMask), never by hand.

filterTFilter | null

The filter whose effects run over what this box, and everything under it, draws, or null. Set by the filter's add (useFilter), never by hand.

parallax{ x, y } | null

How much this box, and everything under it, moves with the camera: useParallax. null moves as everything does. A drawable's own parallax wins over it.

visibleboolean

Whether this box and everything under it is drawn. Inherited downwards, so turning off a turret takes its barrel, its flash and its shadow with it.

Two levels, and both are useful: this one answers "is this object here at all", the visible on a drawable answers "is this one picture of it drawn".

Hiding is not disabling. A hidden box still runs its useUpdate, still plays its sounds and still loads what it asked for. Something that has to stop as well as disappear has to be told to stop.

View source · hooks/spawn/use_spawn.ts:18

TLinestypenacatamalon

A set of lines in space: plain, unlit, one colour per corner. What the debug helpers draw (an axis gizmo, a floor grid, an outline), and anything else that is best said with a line.

The corners are not here. A record is plain data and a run of numbers the card reads is not, so they live beside it, and setLines is what writes them. What is here is what an ordinary drawable has, where it is and whether it is drawn, and changing those is all it takes for the next frame to show it.

Lines are hidden by the models in front of them, and hide what is behind them, the same as a model: a line that ignored the scene would read as a wireframe floating over it. They are one pixel wide on both backends, which is all the cards promise.

Properties

idstring
type'lines'
nameoptionalstring

What to call it when you look at it, in a debugger or a log of your own. The engine never looks it up: to find an object, name its box and findObject it.

transformTTransform3d

Where the lines are drawn from: their corners are measured from here, turned and scaled by it.

worldMatrixoptionalFloat32Array

Where it ends up once everything above it has moved it, or where it is when nothing does. Set each frame it is drawn; undefined before its first. Never authored.

zIndexoptionalnumber

Draw order within its scene. On a tie, lines and models are drawn in the order they were made.

visibleoptionalboolean

Whether they are drawn at all. Omitted is drawn.

destroyedboolean

Set by destroy, on it or on the object it belongs to, and never cleared.

View source · gameobjects/lines/types/t_lines.ts:20

TMeshtypenacatamalon

A model: a shape, put somewhere, with a surface.

The shape is shared and the placement is its own, which is the whole split: a hundred crates are one shape and a hundred of these. Plain data, like every other drawable, so changing a field is all it takes and the next frame shows it.

The surface is a material, and a shared one: a hundred crates are one shape, one surface and a hundred of these. A sprite is the other way round and keeps its own picture and colour, because in two dimensions those vary per sprite and travel with it in the instance buffer.

So the question this used to leave open, of what a material is and what sharing one would mean, turned out to have two answers rather than one, which is exactly why it was worth leaving open.

Properties

idstring
type'mesh'
geometryTGeometry | null

What shape it is. null draws nothing, which is what a model waiting on a file does.

transformTTransform3d

Where it is, how it is turned and how big.

worldMatrixoptionalFloat32Array

Where it ends up once everything above it has moved it, or where it is when nothing does. Set each frame it is drawn, so it is there from the first useUpdate after it is in a scene; undefined before that. Never authored.

skeletonTSkeleton | null

The bones that move it, or null for something that does not bend.

It comes from a model that was rigged, and it is what decides how this is drawn: with bones, every corner is carried by up to four of them; without, it sits where its placement puts it.

materialTMeshMaterial

What it looks like: its picture, its colours, its shine, and any shader of its own.

Never null. A model built without being handed one gets a private material of its own, made from the very same fields it used to carry, so createMesh({ tint }) still reads the way it always did. Handing two models the same material is how they come to share a surface, and with a shader on it, a single compiled pipeline.

zIndexoptionalnumber

Draw order within its scene, the same one sprites use. On a tie, models are drawn first.

visibleoptionalboolean

Whether it is drawn at all. Omitted is drawn.

castShadowoptionalboolean

Whether it is drawn into the shadow map. Omitted casts, which is what nearly everything should do; false is for a floor, a decal or a blob shadow's own disc.

alwaysDrawnoptionalboolean

Drawn even when nothing of it is on screen. Omitted, it is skipped while it is wholly outside what the camera sees.

boundsMarginoptionalnumber

How far past its shape it can reach, in its own units, before it is judged off screen. Needed by a material that moves its corners in its shader, which is never skipped without it.

instancesoptionalTMeshInstanceRun | null

The run of instances it is drawn as, for one made by createMeshInstances: the shape many times over in one draw. Absent for an ordinary model. Never authored.

destroyedboolean

Set by destroy, on it or on the object it belongs to, and never cleared.

View source · gameobjects/mesh/types/t_mesh.ts:25

TMeshInstancePlacementtypenacatamalon

Where one instance is, inside the model it belongs to, and what is its own. Everything left out is the plain answer: at the model's middle, unturned, its own size, white, and four zeros.

Properties

xoptionalnumber
yoptionalnumber
zoptionalnumber
rotationoptionalnumber

Its turn about each axis, in radians, as a model's own: rotation about Z.

rotationXoptionalnumber
rotationYoptionalnumber
quaternionoptionalTQuat | null

Its turn as a quaternion, which wins over the three angles when given.

scaleoptionalnumber

Its size, the same every way. scaleX, scaleY and scaleZ say one way apart.

scaleXoptionalnumber
scaleYoptionalnumber
scaleZoptionalnumber
tintoptionalTColorOption

Its colour, multiplied into the colour painted on the shape's corners and so into the material's own tint: white leaves it as it is. Its alpha below 1 is only seen through on a material that is transparent, or cut out with alphaCutoff; on any other it still hides what is drawn behind it after it.

dataoptionaltypeOperator

Four numbers of its own, for the material's corner hook to read as ctx.instance: a seed, how tall, how far along it is. Fewer than four are followed by zeros.

View source · gameobjects/mesh/types/t_mesh_instances.ts:15

TMeshInstanceRuntypenacatamalon

The run of instances behind a createMeshInstances: its numbers here and on the card. The renderer reads buffer, count and bounds; the rest is how the game keeps them up to date. Never authored: write through set and count.

Properties

bufferIBuffer | null

The run on the card, made the first frame it is drawn.

countnumber

How many are drawn: the model's count, kept within what there is room for.

bounds{ min, max } | null

The box every drawn instance fits in, in the model's own space, measured again when one changes. null until the shape has a box of its own.

dataFloat32Array

Twenty numbers an instance: the three rows of its placement, its colour, its four numbers.

capacitynumber

How many there is room for.

dirtyFromnumber

The first instance written since the run last went up, and the one after the last. Equal when nothing has changed.

dirtyTonumber
measured{ box, count } | null

What bounds was measured for: the shape's own box and how many were drawn. null asks for it to be measured again.

View source · gameobjects/mesh/types/t_mesh_instances.ts:59

TMeshInstancestypenacatamalon

TMeshInstances: TMesh & { instances, count, capacity, set }

Many of one shape, drawn in one go: what createMeshInstances gives back. A model like any other (its transform moves them all, its material is their surface), with a place for each instance.

Properties

countnumber

How many are drawn, from the first. Starts at none and grows as set writes further along; lower it to draw fewer, raise it again to draw them back. Never more than capacity. A set past it raises it to reach that instance, so lower it again after setting ones that stay hidden.

capacitynumber

How many there is room for, said when it was made.

set(index: number, placement?: TMeshInstancePlacement) => void

Says where instance index is and what is its own, whole: anything left out goes back to the plain answer rather than staying as it was. Sent to the card once, on the next frame, however many were set.

idstring
type'mesh'
geometryTGeometry | null

What shape it is. null draws nothing, which is what a model waiting on a file does.

transformTTransform3d

Where it is, how it is turned and how big.

worldMatrixoptionalFloat32Array

Where it ends up once everything above it has moved it, or where it is when nothing does. Set each frame it is drawn, so it is there from the first useUpdate after it is in a scene; undefined before that. Never authored.

skeletonTSkeleton | null

The bones that move it, or null for something that does not bend.

It comes from a model that was rigged, and it is what decides how this is drawn: with bones, every corner is carried by up to four of them; without, it sits where its placement puts it.

materialTMeshMaterial

What it looks like: its picture, its colours, its shine, and any shader of its own.

Never null. A model built without being handed one gets a private material of its own, made from the very same fields it used to carry, so createMesh({ tint }) still reads the way it always did. Handing two models the same material is how they come to share a surface, and with a shader on it, a single compiled pipeline.

zIndexoptionalnumber

Draw order within its scene, the same one sprites use. On a tie, models are drawn first.

visibleoptionalboolean

Whether it is drawn at all. Omitted is drawn.

castShadowoptionalboolean

Whether it is drawn into the shadow map. Omitted casts, which is what nearly everything should do; false is for a floor, a decal or a blob shadow's own disc.

alwaysDrawnoptionalboolean

Drawn even when nothing of it is on screen. Omitted, it is skipped while it is wholly outside what the camera sees.

boundsMarginoptionalnumber

How far past its shape it can reach, in its own units, before it is judged off screen. Needed by a material that moves its corners in its shader, which is never skipped without it.

instancesoptionalTMeshInstanceRun | null

The run of instances it is drawn as, for one made by createMeshInstances: the shape many times over in one draw. Absent for an ordinary model. Never authored.

destroyedboolean

Set by destroy, on it or on the object it belongs to, and never cleared.

View source · gameobjects/mesh/types/t_mesh_instances.ts:102

TMeshInstancesOptionstypenacatamalon

TMeshInstancesOptions: TMeshOptions & { capacity }

What createMeshInstances is asked for: everything createMesh is, and how many there is room for.

Properties

capacitynumber

How many instances there is room for. Fixed: the run on the card is made this long once.

geometryTGeometry

The shape it is, from one of the shape hooks.

materialoptionalTMeshMaterial

A surface to draw it with, from createMaterial, shared with anything else handed the same one.

Given one, its surface fields (tint, emissive, specular and the rest of TMeshSurfaceOptions) are not read: the material already says all of that, and two places saying it would be two places to disagree.

textureoptionalTTexture

A picture for its surface, from useLoadTexture.

keyoptionalstring

The key a texture was loaded under, for a model built where the picture is not at hand.

emissiveoptionalTColorOption

Light it gives off by itself. Default none.

emissiveTextureoptionalTTexture

A picture the glow comes through, multiplied by emissive: white where it glows, black where it does not. Default none, the glow the same all over.

occlusionoptionalTTexture | TMaterialOcclusion

Where the light from all around is kept out of its creases, the shading a modelling program calls occlusion: a picture whose red is white where the surface is open and black where it is shut in. It darkens only the scene's ambient, never a lamp or the sun. The picture alone, or { texture, strength, uv, wrap } to apply less of it, lay it out by a second picture coordinate or give it edges of its own (see TMaterialOcclusion). Default none.

transformoptionalPartial<TTransform3d>

Where it is. Anything left out is at the origin, unturned and unscaled.

zIndexoptionalnumber

Draw order within its scene. Default 0, and on a tie a model goes under a sprite.

visibleoptionalboolean

Whether it is drawn. Default true.

castShadowoptionalboolean

Whether it is drawn into the shadow map. Default true.

false is for the things a shadow of would be wrong rather than expensive: the ground the shadows land on, a decal, a pane of glass, the soft disc of a blob shadow. None of it costs anything unless some light in the scene asked to cast in the first place.

There is no matching receiveShadow. Everything drawn in three dimensions receives, including a model wearing a shader you wrote yourself, because a surface that silently stopped taking shadows the moment you gave it an effect is a surprise with nothing to explain it.

alwaysDrawnoptionalboolean

Drawn even when nothing of it is on screen. Default false: a model whose box is wholly outside what the camera sees is skipped that frame, which is what keeps a big world cheap.

For when that box lies and you would rather not say by how much: something a shader of yours throws far from where it was made. boundsMargin says by how much instead, and keeps the saving.

boundsMarginoptionalnumber

How far past its own shape it can reach, in its own units: the height a wave of a vertex shader lifts it, an arm stretched further than any of its movements does. Its box grows by that much on every side before it is judged on or off screen.

A material that moves its corners in its shader cannot be measured from here, so a model wearing one is never skipped until this says how far they go. Bones are measured already: a model that bends is judged in the pose it is in.

tintoptionalTColorOption

Multiplies its colour: its picture's, or the colours a model's file gave each piece, so they are kept and shaded. White, the default, leaves it as it is. Any colour: '#c08040', 0xc08040.

alphaoptionalnumber

How solid it is, 0 to 1. Default 1.

transparentoptionalboolean

Drawn as see-through even at full alpha: for a shader that works out its own alpha, or a picture with see-through parts. Omitted, it is see-through when alpha or its tint's own is below 1, or when a model's file says a piece is (alphaMode: 'BLEND'). A see-through model is drawn after the solid ones, furthest first, and hides nothing.

blendoptional'alpha' | 'additive'

How it lands on what is behind it. 'alpha' (the default) covers it as far as its alpha says. 'additive' adds its colour instead, so it can only brighten: a flash, a hologram, a shield, a beam of light, a magic circle. Its alpha says how much of it is added. An additive model is always drawn as see-through (after the solid ones, hiding nothing, whatever transparent says), casts no shadow, since light added blocks none, and fades into the fog by adding less rather than by turning the fog's colour.

specularoptionalTColorOption

The colour of its shine. Default none, which is a matt surface: a shine is the thing that makes something read as wet, polished or metal, and everything else looks better without it.

shininessoptionalnumber

How tight that shine is. Default 32. Higher is smaller and harder.

vertexSnapoptionalboolean | number

Its corners land on a coarse grid of the screen, the way the PlayStation drew them: a model shivers as it moves and its edges crawl as the camera turns. A number is how many rows the grid has (120 is the classic look, smaller is wilder); true uses the game's own rows, which is subtle. Left out, the scene's render style decides (useRenderStyle), and with none it is off; false, or 0, says no to that style.

affineoptionalboolean

Its picture is stretched straight across the screen without correcting for depth, the way the PlayStation drew it: big flat surfaces bend and swim as the camera comes close. Left out, the scene's render style decides (useRenderStyle), and with none it is off; false says no to it.

perPixeloptionalboolean

Its light is worked out at every pixel rather than at its corners: a shine is a round, clean spot that slides across the surface however few triangles the model has, the look of the computer graphics of the era (glossy plastic, chrome). It costs more per pixel. Left out, the scene's render style decides (useRenderStyle), and with none it is off; false says no to it.

reflectionoptionalTTexture | TMaterialReflection

What its surface reflects: a round picture of its surroundings, and how much in front and at the edge (see TMaterialReflection). The picture alone is a glossy plastic; front: 0.9 is chrome. Default none.

normalMapoptionalTTexture | TMaterialNormalMap

A normal map that bends its surface at every pixel: the picture, or { texture, strength }. See the material's normalMap.

uvTransformoptionalTMaterialUvTransform

Its picture laid moved from where its shape puts it: repeated, turned and slid, { scale, rotation, offset }. See the material's uvTransform. A model file's own is read from the file, and this one is laid in its place.

culloptionalTCullMode

Which side of its triangles is thrown away. 'back' (the default) is a shape seen from outside; 'front' one seen from inside, such as a dome of sky; 'none' draws both sides, each lit as the side it is, for a leaf, a sheet or the top of a liquid.

alphaCutoffoptionalnumber

Cuts its picture out instead of blending it: a pixel whose alpha is below this number is not drawn, every other one is drawn solid. For a fence, a leaf, grass or a paper figure, which then hides what is behind it and casts the shadow of its shape. 0.5 is the usual; from 0 to 1. Omitted, nothing is cut (a model file's MASK pieces bring their own).

smoothoptionalboolean

Overrides the game's smooth for this model alone.

wrapoptionalTTextureWrap | { u, v }

What its picture does past its edge. Default 'repeat', or what a model's file asked for each piece, which is almost always to repeat.

View source · gameobjects/mesh/types/t_mesh_instances.ts:129

TMeshOptionstypenacatamalon

TMeshOptions: T3dOptions & { geometry, material, texture, key, emissive, emissiveTexture, occlusion }

What createMesh is asked for. Only the shape is needed.

Properties

geometryTGeometry

The shape it is, from one of the shape hooks.

materialoptionalTMeshMaterial

A surface to draw it with, from createMaterial, shared with anything else handed the same one.

Given one, its surface fields (tint, emissive, specular and the rest of TMeshSurfaceOptions) are not read: the material already says all of that, and two places saying it would be two places to disagree.

textureoptionalTTexture

A picture for its surface, from useLoadTexture.

keyoptionalstring

The key a texture was loaded under, for a model built where the picture is not at hand.

emissiveoptionalTColorOption

Light it gives off by itself. Default none.

emissiveTextureoptionalTTexture

A picture the glow comes through, multiplied by emissive: white where it glows, black where it does not. Default none, the glow the same all over.

occlusionoptionalTTexture | TMaterialOcclusion

Where the light from all around is kept out of its creases, the shading a modelling program calls occlusion: a picture whose red is white where the surface is open and black where it is shut in. It darkens only the scene's ambient, never a lamp or the sun. The picture alone, or { texture, strength, uv, wrap } to apply less of it, lay it out by a second picture coordinate or give it edges of its own (see TMaterialOcclusion). Default none.

transformoptionalPartial<TTransform3d>

Where it is. Anything left out is at the origin, unturned and unscaled.

zIndexoptionalnumber

Draw order within its scene. Default 0, and on a tie a model goes under a sprite.

visibleoptionalboolean

Whether it is drawn. Default true.

castShadowoptionalboolean

Whether it is drawn into the shadow map. Default true.

false is for the things a shadow of would be wrong rather than expensive: the ground the shadows land on, a decal, a pane of glass, the soft disc of a blob shadow. None of it costs anything unless some light in the scene asked to cast in the first place.

There is no matching receiveShadow. Everything drawn in three dimensions receives, including a model wearing a shader you wrote yourself, because a surface that silently stopped taking shadows the moment you gave it an effect is a surprise with nothing to explain it.

alwaysDrawnoptionalboolean

Drawn even when nothing of it is on screen. Default false: a model whose box is wholly outside what the camera sees is skipped that frame, which is what keeps a big world cheap.

For when that box lies and you would rather not say by how much: something a shader of yours throws far from where it was made. boundsMargin says by how much instead, and keeps the saving.

boundsMarginoptionalnumber

How far past its own shape it can reach, in its own units: the height a wave of a vertex shader lifts it, an arm stretched further than any of its movements does. Its box grows by that much on every side before it is judged on or off screen.

A material that moves its corners in its shader cannot be measured from here, so a model wearing one is never skipped until this says how far they go. Bones are measured already: a model that bends is judged in the pose it is in.

tintoptionalTColorOption

Multiplies its colour: its picture's, or the colours a model's file gave each piece, so they are kept and shaded. White, the default, leaves it as it is. Any colour: '#c08040', 0xc08040.

alphaoptionalnumber

How solid it is, 0 to 1. Default 1.

transparentoptionalboolean

Drawn as see-through even at full alpha: for a shader that works out its own alpha, or a picture with see-through parts. Omitted, it is see-through when alpha or its tint's own is below 1, or when a model's file says a piece is (alphaMode: 'BLEND'). A see-through model is drawn after the solid ones, furthest first, and hides nothing.

blendoptional'alpha' | 'additive'

How it lands on what is behind it. 'alpha' (the default) covers it as far as its alpha says. 'additive' adds its colour instead, so it can only brighten: a flash, a hologram, a shield, a beam of light, a magic circle. Its alpha says how much of it is added. An additive model is always drawn as see-through (after the solid ones, hiding nothing, whatever transparent says), casts no shadow, since light added blocks none, and fades into the fog by adding less rather than by turning the fog's colour.

specularoptionalTColorOption

The colour of its shine. Default none, which is a matt surface: a shine is the thing that makes something read as wet, polished or metal, and everything else looks better without it.

shininessoptionalnumber

How tight that shine is. Default 32. Higher is smaller and harder.

vertexSnapoptionalboolean | number

Its corners land on a coarse grid of the screen, the way the PlayStation drew them: a model shivers as it moves and its edges crawl as the camera turns. A number is how many rows the grid has (120 is the classic look, smaller is wilder); true uses the game's own rows, which is subtle. Left out, the scene's render style decides (useRenderStyle), and with none it is off; false, or 0, says no to that style.

affineoptionalboolean

Its picture is stretched straight across the screen without correcting for depth, the way the PlayStation drew it: big flat surfaces bend and swim as the camera comes close. Left out, the scene's render style decides (useRenderStyle), and with none it is off; false says no to it.

perPixeloptionalboolean

Its light is worked out at every pixel rather than at its corners: a shine is a round, clean spot that slides across the surface however few triangles the model has, the look of the computer graphics of the era (glossy plastic, chrome). It costs more per pixel. Left out, the scene's render style decides (useRenderStyle), and with none it is off; false says no to it.

reflectionoptionalTTexture | TMaterialReflection

What its surface reflects: a round picture of its surroundings, and how much in front and at the edge (see TMaterialReflection). The picture alone is a glossy plastic; front: 0.9 is chrome. Default none.

normalMapoptionalTTexture | TMaterialNormalMap

A normal map that bends its surface at every pixel: the picture, or { texture, strength }. See the material's normalMap.

uvTransformoptionalTMaterialUvTransform

Its picture laid moved from where its shape puts it: repeated, turned and slid, { scale, rotation, offset }. See the material's uvTransform. A model file's own is read from the file, and this one is laid in its place.

culloptionalTCullMode

Which side of its triangles is thrown away. 'back' (the default) is a shape seen from outside; 'front' one seen from inside, such as a dome of sky; 'none' draws both sides, each lit as the side it is, for a leaf, a sheet or the top of a liquid.

alphaCutoffoptionalnumber

Cuts its picture out instead of blending it: a pixel whose alpha is below this number is not drawn, every other one is drawn solid. For a fence, a leaf, grass or a paper figure, which then hides what is behind it and casts the shadow of its shape. 0.5 is the usual; from 0 to 1. Omitted, nothing is cut (a model file's MASK pieces bring their own).

smoothoptionalboolean

Overrides the game's smooth for this model alone.

wrapoptionalTTextureWrap | { u, v }

What its picture does past its edge. Default 'repeat', or what a model's file asked for each piece, which is almost always to repeat.

View source · gameobjects/mesh/types/t_mesh_options.ts:14

TMeshSurfaceOptionstypenacatamalon

How the surface of a lit model is painted: what ends up in its material. A model placed from a file has the same, laid over each piece's own.

Properties

tintoptionalTColorOption

Multiplies its colour: its picture's, or the colours a model's file gave each piece, so they are kept and shaded. White, the default, leaves it as it is. Any colour: '#c08040', 0xc08040.

alphaoptionalnumber

How solid it is, 0 to 1. Default 1.

transparentoptionalboolean

Drawn as see-through even at full alpha: for a shader that works out its own alpha, or a picture with see-through parts. Omitted, it is see-through when alpha or its tint's own is below 1, or when a model's file says a piece is (alphaMode: 'BLEND'). A see-through model is drawn after the solid ones, furthest first, and hides nothing.

blendoptional'alpha' | 'additive'

How it lands on what is behind it. 'alpha' (the default) covers it as far as its alpha says. 'additive' adds its colour instead, so it can only brighten: a flash, a hologram, a shield, a beam of light, a magic circle. Its alpha says how much of it is added. An additive model is always drawn as see-through (after the solid ones, hiding nothing, whatever transparent says), casts no shadow, since light added blocks none, and fades into the fog by adding less rather than by turning the fog's colour.

specularoptionalTColorOption

The colour of its shine. Default none, which is a matt surface: a shine is the thing that makes something read as wet, polished or metal, and everything else looks better without it.

shininessoptionalnumber

How tight that shine is. Default 32. Higher is smaller and harder.

vertexSnapoptionalboolean | number

Its corners land on a coarse grid of the screen, the way the PlayStation drew them: a model shivers as it moves and its edges crawl as the camera turns. A number is how many rows the grid has (120 is the classic look, smaller is wilder); true uses the game's own rows, which is subtle. Left out, the scene's render style decides (useRenderStyle), and with none it is off; false, or 0, says no to that style.

affineoptionalboolean

Its picture is stretched straight across the screen without correcting for depth, the way the PlayStation drew it: big flat surfaces bend and swim as the camera comes close. Left out, the scene's render style decides (useRenderStyle), and with none it is off; false says no to it.

perPixeloptionalboolean

Its light is worked out at every pixel rather than at its corners: a shine is a round, clean spot that slides across the surface however few triangles the model has, the look of the computer graphics of the era (glossy plastic, chrome). It costs more per pixel. Left out, the scene's render style decides (useRenderStyle), and with none it is off; false says no to it.

reflectionoptionalTTexture | TMaterialReflection

What its surface reflects: a round picture of its surroundings, and how much in front and at the edge (see TMaterialReflection). The picture alone is a glossy plastic; front: 0.9 is chrome. Default none.

normalMapoptionalTTexture | TMaterialNormalMap

A normal map that bends its surface at every pixel: the picture, or { texture, strength }. See the material's normalMap.

uvTransformoptionalTMaterialUvTransform

Its picture laid moved from where its shape puts it: repeated, turned and slid, { scale, rotation, offset }. See the material's uvTransform. A model file's own is read from the file, and this one is laid in its place.

culloptionalTCullMode

Which side of its triangles is thrown away. 'back' (the default) is a shape seen from outside; 'front' one seen from inside, such as a dome of sky; 'none' draws both sides, each lit as the side it is, for a leaf, a sheet or the top of a liquid.

alphaCutoffoptionalnumber

Cuts its picture out instead of blending it: a pixel whose alpha is below this number is not drawn, every other one is drawn solid. For a fence, a leaf, grass or a paper figure, which then hides what is behind it and casts the shadow of its shape. 0.5 is the usual; from 0 to 1. Omitted, nothing is cut (a model file's MASK pieces bring their own).

smoothoptionalboolean

Overrides the game's smooth for this model alone.

wrapoptionalTTextureWrap | { u, v }

What its picture does past its edge. Default 'repeat', or what a model's file asked for each piece, which is almost always to repeat.

View source · gameobjects/types/t_3d_options.ts:14

TModeltypenacatamalon

A loaded model placed in the scene: one placement, and the pieces it is made of.

Move the placement and all of it moves, however many pieces the file turned out to hold. What is set on the model (tint, alpha, zIndex, castShadow, visible) goes to every piece at once, the ones still on the way too, and destroy(model) takes them all. The pieces are ordinary models of their own, so one alone can still be changed through parts: the glass of a car.

parts fills in when the file arrives, so it is empty on the frame you make this and has what the file held on a later one. Look a piece up by the name it had in the file when you need one in particular.

Properties

idstring
type'model'
transformTTransform3d

Where the whole thing is. Shared by every piece, which is what moves them together.

modelTGltfModel

The file it was placed from, with the movements it knows (clips).

partsTMesh[]

The pieces, in the order the file lists them. Empty until it arrives.

skeletonsTSkeleton[]

Its own bones, one set per skeleton in the file, which its pieces wear: what useSkeletalAnimation moves. Its own and not the file's, so two models placed from one file stand, walk and jump each on their own. Empty until the file arrives.

visibleboolean

Whether any of it is drawn. Setting it hides or shows every piece at once, and holds for the pieces still on the way too: hidden before the file arrives, they arrive hidden.

A piece can still be hidden on its own through parts; this overwrites them all.

tintTColor

Multiplies the colour of every piece, so the file's own colours are kept and shaded: white leaves it as it was made. Setting it shades them all at once, a flash of red on a hit: enemy.tint = getColor('red'). It takes any colour, and reads back as { r, g, b, a }.

alphanumber

How solid every piece is, 0 to 1. Setting it fades them all at once.

zIndexnumber

Draw order within its scene, for every piece. 0 by default.

castShadowboolean

Whether its pieces throw a shadow. true by default.

alwaysDrawnboolean

Whether every piece is drawn even off screen. false by default: a piece wholly outside what the camera sees is skipped.

boundsMarginnumber | undefined

How far past its shape each piece can reach, in its own units, before it is judged off screen. undefined until it is said.

destroyedboolean

true once destroy(model) has been asked: its pieces are gone, and one still on the way never comes.

View source · gameobjects/model/types/t_model.ts:23

TModelOptionstypenacatamalon

TModelOptions: T3dOptions & { model, lighting, steps }

What createModel is asked for. Only the model is needed.

Properties

modelTGltfModel

The loaded model, from useLoadModel.

lightingoptionalTLightingLook

How every piece is lit, in place of the engine's light: toonLighting() or unlitLighting(). Each piece keeps its own picture and colour from the file. A model with bones bends and is lit by it alike.

stepsoptionaltypeOperator

What is done to every piece once it is lit, in order: mangaDots(), rim(), groundBounce().

transformoptionalPartial<TTransform3d>

Where it is. Anything left out is at the origin, unturned and unscaled.

zIndexoptionalnumber

Draw order within its scene. Default 0, and on a tie a model goes under a sprite.

visibleoptionalboolean

Whether it is drawn. Default true.

castShadowoptionalboolean

Whether it is drawn into the shadow map. Default true.

false is for the things a shadow of would be wrong rather than expensive: the ground the shadows land on, a decal, a pane of glass, the soft disc of a blob shadow. None of it costs anything unless some light in the scene asked to cast in the first place.

There is no matching receiveShadow. Everything drawn in three dimensions receives, including a model wearing a shader you wrote yourself, because a surface that silently stopped taking shadows the moment you gave it an effect is a surprise with nothing to explain it.

alwaysDrawnoptionalboolean

Drawn even when nothing of it is on screen. Default false: a model whose box is wholly outside what the camera sees is skipped that frame, which is what keeps a big world cheap.

For when that box lies and you would rather not say by how much: something a shader of yours throws far from where it was made. boundsMargin says by how much instead, and keeps the saving.

boundsMarginoptionalnumber

How far past its own shape it can reach, in its own units: the height a wave of a vertex shader lifts it, an arm stretched further than any of its movements does. Its box grows by that much on every side before it is judged on or off screen.

A material that moves its corners in its shader cannot be measured from here, so a model wearing one is never skipped until this says how far they go. Bones are measured already: a model that bends is judged in the pose it is in.

tintoptionalTColorOption

Multiplies its colour: its picture's, or the colours a model's file gave each piece, so they are kept and shaded. White, the default, leaves it as it is. Any colour: '#c08040', 0xc08040.

alphaoptionalnumber

How solid it is, 0 to 1. Default 1.

transparentoptionalboolean

Drawn as see-through even at full alpha: for a shader that works out its own alpha, or a picture with see-through parts. Omitted, it is see-through when alpha or its tint's own is below 1, or when a model's file says a piece is (alphaMode: 'BLEND'). A see-through model is drawn after the solid ones, furthest first, and hides nothing.

blendoptional'alpha' | 'additive'

How it lands on what is behind it. 'alpha' (the default) covers it as far as its alpha says. 'additive' adds its colour instead, so it can only brighten: a flash, a hologram, a shield, a beam of light, a magic circle. Its alpha says how much of it is added. An additive model is always drawn as see-through (after the solid ones, hiding nothing, whatever transparent says), casts no shadow, since light added blocks none, and fades into the fog by adding less rather than by turning the fog's colour.

specularoptionalTColorOption

The colour of its shine. Default none, which is a matt surface: a shine is the thing that makes something read as wet, polished or metal, and everything else looks better without it.

shininessoptionalnumber

How tight that shine is. Default 32. Higher is smaller and harder.

vertexSnapoptionalboolean | number

Its corners land on a coarse grid of the screen, the way the PlayStation drew them: a model shivers as it moves and its edges crawl as the camera turns. A number is how many rows the grid has (120 is the classic look, smaller is wilder); true uses the game's own rows, which is subtle. Left out, the scene's render style decides (useRenderStyle), and with none it is off; false, or 0, says no to that style.

affineoptionalboolean

Its picture is stretched straight across the screen without correcting for depth, the way the PlayStation drew it: big flat surfaces bend and swim as the camera comes close. Left out, the scene's render style decides (useRenderStyle), and with none it is off; false says no to it.

perPixeloptionalboolean

Its light is worked out at every pixel rather than at its corners: a shine is a round, clean spot that slides across the surface however few triangles the model has, the look of the computer graphics of the era (glossy plastic, chrome). It costs more per pixel. Left out, the scene's render style decides (useRenderStyle), and with none it is off; false says no to it.

reflectionoptionalTTexture | TMaterialReflection

What its surface reflects: a round picture of its surroundings, and how much in front and at the edge (see TMaterialReflection). The picture alone is a glossy plastic; front: 0.9 is chrome. Default none.

normalMapoptionalTTexture | TMaterialNormalMap

A normal map that bends its surface at every pixel: the picture, or { texture, strength }. See the material's normalMap.

uvTransformoptionalTMaterialUvTransform

Its picture laid moved from where its shape puts it: repeated, turned and slid, { scale, rotation, offset }. See the material's uvTransform. A model file's own is read from the file, and this one is laid in its place.

culloptionalTCullMode

Which side of its triangles is thrown away. 'back' (the default) is a shape seen from outside; 'front' one seen from inside, such as a dome of sky; 'none' draws both sides, each lit as the side it is, for a leaf, a sheet or the top of a liquid.

alphaCutoffoptionalnumber

Cuts its picture out instead of blending it: a pixel whose alpha is below this number is not drawn, every other one is drawn solid. For a fence, a leaf, grass or a paper figure, which then hides what is behind it and casts the shadow of its shape. 0.5 is the usual; from 0 to 1. Omitted, nothing is cut (a model file's MASK pieces bring their own).

smoothoptionalboolean

Overrides the game's smooth for this model alone.

wrapoptionalTTextureWrap | { u, v }

What its picture does past its edge. Default 'repeat', or what a model's file asked for each piece, which is almost always to repeat.

View source · gameobjects/model/types/t_model_options.ts:12

TNineSlicetypenacatamalon

A picture cut into nine parts so it can be any size without deforming its corners, as createNineSlice gives it back: the panels, buttons, dialogue boxes and health bars of a UI. Plain data: change any field (width above all) and the next frame shows it.

Properties

idstring
type'nine-slice'
widthnumber

Width in pixels, before scale. Change it and the corners stay as they are.

heightnumber

Height in pixels, before scale.

transformTTransform2d

Where it is, how it is turned and how big. Scale stretches the whole of it, corners included.

worldTransformoptionalTTransform2d

Where it ends up once everything above it has moved it, worked out once a frame while the tree is walked. Left off when nothing above it has a placement of its own, which is the ordinary case: then its own transform is already where it is.

Set by the engine every frame and never authored or saved. Ask worldOf rather than reading either field by hand.

textureTTexture

The picture it is cut from.

tintTColor
sliceTNineSliceBorders

How wide each border is, in pixels of the picture.

modeTNineSliceMode | { x, y }

How the edges and the middle fill their space, the same both ways or one per direction: { x: 'tile', y: 'stretch' } repeats along the width and stretches along the height.

atlasoptionalTSpriteAtlas

The sheet its picture came from, if it came from one.

frameoptionalnumber

Which frame of atlas it is cut from. Change it and the next frame is cut from that one.

uvOffsetoptional{ x, y }

Where the window into the texture starts, in 0-1. Wins over atlas and frame.

uvScaleoptional{ x, y }

How big that window is, in 0-1. Wins over atlas and frame.

anchoroptional{ x, y }

Which point of it sits on its transform, in 0-1. Omitted is its middle, as for a sprite.

pivotoptional{ x, y }

The point it turns and grows about, in 0-1 like anchor, when that is not its anchor: a panel placed by its top-left corner that pops open from its middle. Unturned and ungrown it sits as its anchor says; turned, it turns about this point, anchor and all. Omitted is its anchor. Can be changed at any moment, and taken away (undefined).

zIndexoptionalnumber

Draw order within its scene, as for a sprite. All nine parts move as one.

smoothoptionalboolean

Crisp or blended when it does not land on whole pixels. Omitted, the game's smooth decides.

parallaxoptional{ x, y }

How much it moves with the camera, as for a sprite: 1 (the default) as everything else, 0 not at all. Ignored on what is pinned to the screen. Can be changed any frame.

blendoptional'alpha' | 'additive'

'additive' adds its colour to what is behind it, so it can only brighten; 'alpha' (the default) covers it. Can be changed any frame.

tagsoptionalstring[]

What it is, for something drawn on its own rather than a piece: ['wall']. What useTag adds and finds, and what collisions are asked by. Absent is none.

visibleoptionalboolean

Whether it is drawn at all. Omitted is drawn.

materialoptionalTSpriteMaterial

An effect of its own, from createMaterial, carried by every part. Omitted is the built-in shader.

uniformsoptionalTUniformValues

Its own values for that material's uniforms, laid over the material's own.

destroyedboolean

Set by destroy, on it or on the object it belongs to, and never cleared.

View source · gameobjects/nine_slice/types/t_nine_slice.ts:43

TNineSliceBorderstypenacatamalon

How wide each border of a nine-slice is, in pixels of its picture (of its frame, with a sheet). Those borders are what is never stretched: the corners stay as drawn, and the edges only grow along their length.

Properties

leftnumber
topnumber
rightnumber
bottomnumber
View source · gameobjects/nine_slice/types/t_nine_slice.ts:32

TNineSliceModetypenacatamalon

TNineSliceMode: 'stretch' | 'tile' | 'tile-fit'

How the parts of a nine-slice between its corners fill the space they are given.

  • 'stretch': the part is drawn once, stretched to fit. The default, and what a plain panel wants.
  • 'tile': the part is repeated at its own size from the corner onwards, and the last copy is cut where the space ends. For a frame with a pattern along it (rivets, a rope, bricks) that must not be deformed.
  • 'tile-fit': repeated as many whole times as fit best, each copy stretched a little so none is cut. The pattern stays whole at the cost of being slightly wider or narrower than drawn.
View source · gameobjects/nine_slice/types/t_nine_slice.ts:21

TNineSliceOptionstypenacatamalon

TNineSliceOptions: T2dOptions & { texture, key, atlas, frame, uvOffset, uvScale, slice, mode, width, height }

What createNineSlice is asked for: a picture, how wide its borders are, and the size to draw it at.

Properties

textureoptionalTTexture | string

Its picture: a texture from useLoadTexture, or the key it was loaded under ('panel'). Wins over key and atlas.

keyoptionalstring

The key a texture was loaded under.

atlasoptionalTSpriteAtlas

A sheet from createSpriteAtlas, with frame saying which part of it is the picture.

frameoptionalnumber

Which frame of atlas, numbered from 0. Default 0.

uvOffsetoptional{ x, y }

Where the picture starts inside the texture, in 0-1, for a picture that is not a whole frame.

uvScaleoptional{ x, y }

How big the picture is inside the texture, in 0-1.

slicenumber | TNineSliceBorders

How wide each border is, in pixels of the picture: one number for all four, or each one. The borders are the part that is never stretched, so they are usually the size of the corners as drawn.

modeoptionalTNineSliceMode | { x, y }

How the edges and the middle fill their space: 'stretch' (the default), 'tile' or 'tile-fit', the same both ways or { x, y } one per direction.

widthnumber

How wide to draw it, in pixels. Required: drawn at the size of its picture it would cut nothing, and a sprite already does that.

heightnumber

How tall to draw it, in pixels.

transformoptionalPartial<TTransform2d>

Where it is, how it is turned and how big. Only what is given: the rest is no turn and a scale of 1, so { x, y } is enough. Copied, so the object handed in stays the caller's.

anchoroptional{ x, y }

Which point of it sits on its transform, in 0-1 of its own size: { x: 0.5, y: 0.5 } is its middle, { x: 0.5, y: 1 } the middle of its bottom edge (a character standing on a floor), { x: 0, y: 0 } its top-left corner. Rotation and scale happen around it, unless pivot says another point. Default: the middle for a sprite and a panel, the top-left corner for a text.

They differ on purpose. A thing of the world sits by its middle, the point it turns and grows on; a text sits by its corner so it grows without moving, and a score going from 9 to 10 does not shift. A label centred on a panel gives them both the same anchor.

pivotoptional{ x, y }

The point it turns and grows about, in 0-1 of its own size, when it is not the anchor: the anchor decides where it sits, the pivot what it spins on. A door anchored at its corner turns on its hinge ({ x: 0, y: 0.5 }); a score anchored at its left edge pops bigger from its middle ({ x: 0.5, y: 0.5 }). Default: its anchor.

tintoptionalTColorOption

Its colour, multiplied over what it draws: '#ff6b1a', 0xff6b1a, 'tomato' or a TColor. Default white, drawn as it is. A TColor is copied, so changing this one's tint changes no other thing given the same colour.

visibleoptionalboolean

Whether it is drawn. Default true. false makes it hidden from the start, which is how a set of them is prepared in advance and shown one at a time.

zIndexoptionalnumber

Which others it is drawn in front of, within its own scene: higher numbers go on top, and negatives are allowed. The same number keeps the order they were made in. Default 0. It can be changed at any time and takes effect on the next frame drawn.

smoothoptionalboolean

Crisp (false) or blended (true) when scaled: false keeps pixel art crisp. Default: the game's smooth.

parallaxoptional{ x, y }

How much it moves with the camera: 1 (the default) as everything else, 0 not at all, and in between further away: { x: 0.3, y: 0 } is a far range of mountains that slides slowly by and keeps its height. Only how it is drawn and touched by the pointer: its placement stays what it says. Something pinned to the screen (useScreenSpace, a HUD) does not see the camera, so it has no parallax whatever this says.

blendoptional'alpha' | 'additive'

How it lands on what is behind it. 'alpha' (the default) covers it as far as its alpha says. 'additive' adds its colour instead, so it can only brighten: a halo, a flash, a glowing "LEVEL UP!", a lamp at night. Two additive things over each other are brighter than one. Can be changed any frame.

tagsoptionalstring[]

What it is, as useTag says it: ['wall']. The same as adding them after.

materialoptionalTSpriteMaterial

An effect of its own, from createMaterial. Omitted is the built-in shader.

uniformsoptionalTUniformValues

Its own values for that material's uniforms, laid over the material's own.

onPointerOveroptionalTPointerListener

The pointer comes over the sprite.

onPointerOutoptionalTPointerListener

The pointer stops being over it, or leaves the game.

onPointerMoveoptionalTPointerListener

The pointer moves while over it.

onPointerDownoptionalTPointerListener

A button is pressed, or a finger touches, over it.

onPointerUpoptionalTPointerListener

A button is released, or a finger lifts, over it.

onClickoptionalTPointerListener

Pressed and released without leaving it. The cursor turns into a hand over it.

onDragStartoptionalTPointerDragListener

Pressed with the main button (or a finger) and moved far enough not to be a click: a few pixels of the page, more for a finger, which shakes. Once it starts, the press is a drag and not a click: letting go over it does not call onClick. The cursor turns into an open hand over something that can be dragged, and a closed one while it is.

Nothing moves by itself: the events say what the pointer did, and the game decides what that does (follow it, pull a slingshot back, turn a dial). useDraggable is the one that moves it.

onDragoptionalTPointerDragListener

The pointer that started the drag moved, wherever it is: over the sprite or not, in the game or off its edge. Called right after onDragStart too, so the first move is not lost.

onDragEndoptionalTPointerDragListener

The pointer that dragged it let go, with target and hits saying what it was let go over.

View source · gameobjects/nine_slice/types/t_nine_slice_options.ts:13

TPackOptionstypenacatamalon

What createPack is asked for: which thing of which pack, where, and with which settings.

Properties

packTLoadedPack

The pack, from useLoadPack.

boxoptionalstring

Which of the boxes it offers. Left out, and with scene left out too, the pack's only offer is taken, which is what a pack of one thing wants.

sceneoptionalstring

Which of the scenes it offers, placed as one part of the scene that creates it.

transformoptionalTTransformOptions

Where this copy goes, measured from what creates it. The pack has no place of its own.

propsoptionalTScriptProps

This copy's own settings for the scripts on the thing itself (not its children), laid over the ones the pack was made with. What a door's destination or a patrol's speed is for.

onoptionalRecord<string, TReportHandler>

What to do when the copy reports something: what its behaviours send with useReport (a button's 'pressed'), by name. The same as onReport on the copy, connected before the pack has even landed.

View source · gameobjects/pack/types/t_pack_options.ts:13

TParticlestypenacatamalon

An emitter: a place in the world that makes particles, following an effect written in a file.

Plain data from end to end, like every other record here. Its living particles, its own stream of chance and the numbers bound for the card are not any of those things, so they are kept beside it rather than in it, and found by it. That is what lets an emitter be written to a scene file at all: what would be written is what is here, and all of it is JSON.

Properties

type'particles'
idstring
namestring

What a warning about it will call it. Defaults to the file it came from.

fileTParticlesFile

The effect it follows. Filled in when the file lands; until then it draws nothing.

transformTTransform2d

Where the emitter is. Particles are born here, turned by whatever is above it.

worldTransformoptionalTTransform2d

Where it ended up once everything above it has moved it, when something did.

Set by the engine every frame and never authored or saved. Ask worldOf rather than reading either field by hand. It matters more here than for a sprite: this is the point particles are born at, so reading the wrong one puts a whole cloud in the wrong place.

tintTColor

Multiplied into every particle, over the colour the effect's own curve gives it.

alphanumber

Multiplied into every particle's opacity, the same way.

smoothoptionalboolean

Crisp or blended. Default: the game's own setting.

overridesoptionalTParticleOverrides

What this one disagrees with its file about, or nothing.

emittingboolean

Whether new ones are appearing.

Turning this off is not the same as clearing: the ones already alive go on living and drawing, which is what putting out a torch looks like. Runtime state, and deliberately not what gets written to a file.

pausedboolean

Frozen. Nothing moves and nothing is born, and it keeps drawing exactly what it last drew.

Freezing rather than hiding, because the useful half of this is for a host showing the game while somebody works: a still flame is something you can line a box up against, and a hidden one is a hole where you have to remember an effect was.

autoplayboolean

Whether it starts emitting the moment its file lands.

The authored intention, and the only one of these three that belongs in a file. A torch a script put out is still a torch that starts lit, and saving the running state would write "out" into the level.

seednumber | null

The seed for this emitter's own chance, or null for one taken from the clock.

Set it and the effect replays exactly, which is what a screenshot test and an editor preview want. Leave it and every run looks a little different, which is what a game wants.

zIndexoptionalnumber
visibleboolean
destroyedboolean

Set by destroy, on it or on the object it belongs to, and never cleared. True means it is on its way out and nothing should treat it as part of the game any more, even in the gap before the frame sweeps it away.

View source · gameobjects/particles/types/t_particles.ts:49

TParticlesOptionstypenacatamalon

What createParticles is asked for.

Almost everything about the effect itself lives in its file, and that is the point: three torches are one document. What is here is the handful of things this emitter decides for itself.

Properties

effectTParticlesFile | TParticlesEffect | string

The effect: from useLoadParticles, the name one was loaded under, or written right here in code with the same fields a .particles file has.

One written in code is ready at once. Hand the same object to several emitters and they share it, like emitters naming one file; build a new one when it should change, for instance dust the colour of the ground underneath.

nameoptionalstring

What a warning about it will call it. Defaults to the file.

transformoptionalPartial<TTransform2d>

Where it is. Particles are born here, turned and scaled by whatever is above it.

tintoptionalTColorOption

Multiplied into every particle, over the colour the effect's own curve gives it.

alphaoptionalnumber

Multiplied into every particle's opacity, the same way. Default 1.

smoothoptionalboolean

Crisp or blended. Default: the game's own setting.

overridesoptionalTParticleOverrides

What this emitter disagrees with its file about: a smaller explosion, a slower fountain.

autoplayoptionalboolean

Start as soon as the file lands. true by default, because a torch put in a scene should be burning. false for something an event fires.

seedoptionalnumber

Its own seed, so it replays exactly. Omitted, every run looks a little different.

zIndexoptionalnumber

Draw order, as everywhere else.

visibleoptionalboolean

Whether it is drawn at all. Default true.

View source · gameobjects/particles/types/t_particles_options.ts:17

TPolygontypenacatamalon

A shape whose corners the game moves: a picture stretched over an outline that can change every frame. A blob that squashes as it lands, a flag in the wind, a jelly, a rope drawn as a strip.

Where a sprite is always a rectangle, this is whatever the corners say, and the picture goes with them: each corner holds on to its own point of the picture, so pushing a corner out stretches the picture under it. The corners are plain numbers on the record, changed like any other field, and the next frame draws them.

It is drawn from its middle out, a triangle for each side, so it suits any outline that can be seen whole from its middle (a circle squashed any way, a star, a drop). An outline that folds back on itself past its middle is drawn with the fold showing.

Properties

type'polygon'
idstring
nameoptionalstring

What to call it when you look at it, in a debugger or a log of your own. The engine never looks it up: to find an object, name its box and findObject it.

transformTTransform2d

Where it is, turned and scaled. The corners are measured from here.

worldTransformoptionalTTransform2d

Where it ends up once everything above it has moved it. Set by the engine every frame.

points{ x, y }[]

The outline, corner after corner around it, measured from transform. Change them, or the list, at any time.

uvs{ x, y }[]

Which point of the picture each corner holds, from 0, 0 (its top-left) to 1, 1, one per corner. Worked out from the first outline when it is made, so the picture fills it; when the number of corners changes and these no longer match, they are worked out again from the outline as it is then.

textureTTexture | null

The picture, or null for a shape of a plain colour (its tint).

atlasoptionalTSpriteAtlas

A sheet, when the picture is one frame of it.

frameoptionalnumber

Which frame of atlas.

tintTColor

Multiplies the colour of the picture, a as opacity. Its whole colour when it has no picture.

smoothoptionalboolean

How the picture is read. Omitted, the game's own setting decides.

zIndexnumber

Draw order within the scene, as for any other drawing.

visibleoptionalboolean

Whether it is drawn. Default true.

parallaxoptional{ x, y }

How much it moves with the camera, as on a sprite.

destroyedboolean
View source · gameobjects/polygon/types/t_polygon.ts:23

TPolygonOptionstypenacatamalon

What createPolygon is told.

Properties

points{ x, y }[]

The outline, at least three corners, one after the other around it, measured from transform.

uvsoptional{ x, y }[]

Which point of the picture each corner holds, from 0, 0 to 1, 1. Left out, the picture is stretched over the box the outline fits in.

textureoptionalTTexture

The picture. Left out (and no atlas), a shape of a plain colour.

atlasoptionalTSpriteAtlas

A sheet, to show one of its frames.

frameoptionalnumber

Which frame of atlas. 0 by default.

tintoptionalTColorOption

Multiplies the colour of the picture; the colour itself without one. White by default.

transformoptionalPartial<TTransform2d>
zIndexoptionalnumber
visibleoptionalboolean
smoothoptionalboolean
parallaxoptional{ x, y }
nameoptionalstring

What to call it when you look at it. The engine never looks it up: to find it, name its box.

View source · gameobjects/polygon/create_polygon.ts:20

TShapeCircletypenacatamalon

TShapeCircle: TShapeFilled & { type, x, y, radius, start, end, segments }

A circle by its middle, or a slice of one from start to end: filled, a slice of a pie (a cooldown); stroked, the arc alone (a ring that fills up).

Properties

type'circle'
xnumber
ynumber
radiusnumber
startoptionalnumber

Where the slice starts and ends, in radians clockwise from the right; an end before its start goes round the other way. Both left out, or a whole turn or more apart, is the whole circle.

endoptionalnumber
segmentsoptionalnumber

How many straight sides make it up. Left out, as many as keep it round at its size.

View source · gameobjects/shapes/types/t_shapes.ts:89

TShapeEllipsetypenacatamalon

TShapeEllipse: TShapeFilled & { type, x, y, radiusX, radiusY, rotation, start, end, segments }

An ellipse by its middle, turned by rotation, or a slice of one, as a circle is.

Properties

type'ellipse'
xnumber
ynumber
radiusXnumber
radiusYnumber
rotationoptionalnumber
startoptionalnumber
endoptionalnumber
segmentsoptionalnumber
View source · gameobjects/shapes/types/t_shapes.ts:114

TShapePolygontypenacatamalon

TShapePolygon: TShapeFilled & { type, points }

Any outline of three corners or more, one after another round it, hollowed in or not. One whose sides cross is drawn from its middle out, folds showing.

Properties

type'polygon'
points{ x, y }[]
View source · gameobjects/shapes/types/t_shapes.ts:134

TShapeRecttypenacatamalon

TShapeRect: TShapeFilled & { type, x, y, width, height, radius, rotation }

A rectangle, by its top-left corner, with its corners rounded if radius says so.

Properties

type'rect'
xnumber
ynumber
widthnumber
heightnumber
radiusoptionalnumber | [number, number, number, number]

How round its corners are: one radius for all four, or one each, top-left, top-right, bottom-right, bottom-left. Never more than half its shorter side.

rotationoptionalnumber

Turned about its middle, in radians.

View source · gameobjects/shapes/types/t_shapes.ts:64

TShapestypenacatamalon

Shapes drawn by the graphics card as they are each frame: rectangles, rounded or not, circles, ellipses and slices of them, outlines of any number of corners, and lines as wide as asked for, each filled, outlined or both, in any colour. A health bar and its frame, a cooldown, a ship drawn in lines, a chart.

They are plain data, shapes, drawn in the order of the list, each filled first and then outlined: change a number, push one, take one out, and the next frame draws it. However many there are, the card draws them in one go; what they cost is working out their corners again each frame.

Properties

type'shapes'
idstring
nameoptionalstring

What to call it when you look at it, in a debugger or a log of your own. The engine never looks it up: to find an object, name its box and findObject it.

transformTTransform2d

Where it is, turned and scaled. The shapes are measured from here.

worldTransformoptionalTTransform2d

Where it ends up once everything above it has moved it. Set by the engine every frame.

shapesTShape[]

What is drawn, in order. Change it at any time.

tintTColor

Multiplies the colour of all of them, a as opacity.

zIndexnumber

Draw order within the scene, as for any other drawing.

visibleoptionalboolean

Whether it is drawn. Default true.

parallaxoptional{ x, y }

How much it moves with the camera, as on a sprite.

destroyedboolean
View source · gameobjects/shapes/types/t_shapes.ts:178

TShapesOptionstypenacatamalon

What createShapes is told.

Properties

shapesoptionalTShape[]

What is drawn, in order, each filled first and then outlined. Can start empty and be filled in later.

tintoptionalTColorOption

Multiplies the colour of all of them. White by default.

transformoptionalPartial<TTransform2d>
zIndexoptionalnumber
visibleoptionalboolean
parallaxoptional{ x, y }
nameoptionalstring

What to call it when you look at it. The engine never looks it up: to find it, name its box.

View source · gameobjects/shapes/create_shapes.ts:18

TShapeStroketypenacatamalon

The line drawn along a shape's outline, or what a line is.

Properties

widthnumber

How wide, in the game's pixels: it grows with the object's scale and the camera's zoom.

joinoptional'miter' | 'round' | 'bevel'

How two sides meet: a sharp corner ('miter', the default, cut flat when sharper than four widths), a round one, or one cut flat ('bevel').

capoptional'butt' | 'round' | 'square'

How an open line ends: flat at its last point ('butt', the default), round, or flat half a width past it ('square'). A closed outline has no ends.

alignoptional'center' | 'inside' | 'outside'

Where a closed outline's line goes: on it ('center', the default), all inside it, or all outside it. A frame that has to keep within its box is 'inside'.

A see-through line is drawn once where its sides meet while they are long enough for its width; one wider than the shape is narrow, or along sides shorter than it is wide, shows darker where it overlaps itself.

View source · gameobjects/shapes/types/t_shapes.ts:11

TSpawnOptionstypenacatamalon

What every thing a maker makes is called, and where it is placed. A string alone is the name, the usual case: useSpawn(Button, 'Jump').

Properties

nameoptionalstring

What each one is called, for whatever finds it by name: a touch button's action ({ type: 'touch', box: 'Jump' }), findObject, a script's field. Left out, it is the component's function name, which is only a label for warnings: a published build shortens function names, so function Jump may ship as c, and a renamed function would rename it too. Anything looked up by name needs it written here.

tagsoptionalstring[]

What each one is, as useTag says it: ['coin']. The same as useTag('coin').add(useSelf()) in its body, and there before the body runs.

parentoptional'scene' | TGameObject

Left out, each one hangs under whoever is making it: a tank that makes its own turret carries it along. 'scene' puts it at the top of the scene instead, which is what a shot fired from a cannon wants, since it must not swing round with the barrel once it has left. Or any thing already in the scene, to hang under that one.

View source · hooks/spawn/use_spawn.ts:28

TSpritetypenacatamalon

A picture in the scene, as createSprite gives it back. Plain data: change any field (transform.x, tint, visible...) and the next frame shows it.

Properties

idstring
type'sprite'
widthoptionalnumber

Width in pixels, before scale. Omitted, it is drawn as wide as what it shows of its texture (one frame of a sheet, not the whole sheet), and stays omitted: the field is not filled in when the picture loads. That width is texture.width * (uvScale?.x ?? 1) once it has.

heightoptionalnumber

Height in pixels, before scale. Omitted, it is drawn as tall as what it shows of its texture, and stays omitted, as width does: texture.height * (uvScale?.y ?? 1) once it has loaded.

transformTTransform2d
worldTransformoptionalTTransform2d

Where it ends up once everything above it has moved it, worked out once a frame while the tree is walked. Left off when nothing above it has a placement of its own, which is the ordinary case: then its own transform is already where it is.

Set by the engine every frame and never authored or saved. Ask worldOf rather than reading either field by hand.

textureTTexture | null

The image it shows, or null for a plain rectangle of its tint.

tintTColor
atlasoptionalTSpriteAtlas

The sheet its picture came from, if it came from one. Set another and it shows the same frame of that one, image and all (the first, when the new sheet is shorter): walking to attacking is hero.atlas = attacking.

frameoptionalnumber

Which frame of atlas it shows. Set it and that frame shows, as with any other field: chest.frame = 1. An animation sets it too, so a scene saved halfway through a run keeps the picture that was on screen.

animationoptionalTSpriteAnimationDoc

The run a scene document asked it to play, and how fast: what it plays, not how far it has got. Written back when the scene is saved, which is all it is for. The player itself is behaviour and lives in the scene, never in the record.

anchoroptional{ x, y }

Which point of the sprite sits on its transform, in 0-1. Omitted is its middle.

pivotoptional{ x, y }

The point it turns and grows about, in 0-1 like anchor, when that is not its anchor: a motorbike anchored under its back wheel that spins about its middle when it crashes. Unturned and ungrown it sits as its anchor says; turned, it turns about this point, anchor and all. Omitted is its anchor. Can be changed at any moment, and taken away (undefined).

uvOffsetoptional{ x, y }

Where the window into the texture starts, in 0-1. Omitted is the top-left corner.

uvScaleoptional{ x, y }

How big that window is, in 0-1. Omitted is the whole image.

flipXoptionalboolean

Shows its picture mirrored left to right: a character facing the other way, with one drawing instead of two. Omitted is not mirrored.

It mirrors the picture, never the place: a mirrored sprite sits exactly where it sat, and is touched in the same place. That is what tells it apart from a negative scale.

flipYoptionalboolean

The same top to bottom.

tileoptionalboolean

Tiles its picture across its size instead of stretching it: a wall of bricks, a strip of grass, clouds. Set width and height to the size to cover; the picture (or its frame, from an atlas) is laid as many times as fits. Omitted is stretched.

tileOffsetoptional{ x, y }

With tile, where the pattern starts inside the sprite, in its picture's pixels: moving it every frame scrolls the pattern while the sprite stays put. { x: 0, y: 0 } by default.

parallaxoptional{ x, y }

How much it moves with the camera: 1 (the default) as everything else, 0 not at all, as if pinned to the screen, and in between further away: { x: 0.3, y: 0 } is a far range of mountains that slides slowly by and keeps its height. Only how it is drawn and touched by the pointer: its placement stays what it says.

tagsoptionalstring[]

What it is, for something drawn on its own rather than a piece: ['wall']. What useTag adds and finds, and what collisions are asked by. Absent is none.

visibleoptionalboolean

Whether it is drawn at all. Omitted is drawn.

For something that exists and is not on screen: the coins of a level made once and shown as they are needed, the second picture of a character who is facing the other way. Cheaper than making it and destroying it over and over, and it keeps whatever it was carrying.

Hidden is not gone: it is still in the scene, its box still runs every frame, and it is not touched by the pointer while it cannot be seen.

smoothoptionalboolean

How its image is read when it does not land on whole pixels: false keeps it crisp and blocky, true blends. Omitted, the game's smooth decides.

blendoptional'alpha' | 'additive'

How it lands on what is behind it. 'alpha' (the default) covers it as far as its alpha says. 'additive' adds its colour instead, so it can only brighten: a halo, a flash, a beam of light, a lamp at night. Two additive sprites over each other are brighter than one. Can be changed any frame.

materialoptionalTSpriteMaterial

An effect of its own, from createMaterial. Omitted is the built-in shader, which is what nearly every sprite wants.

It carries the effect and nothing else: the picture and the colour above stay the sprite's, because those vary per sprite and travel with it. Two sprites handed the same material share one compiled shader, and still draw in one call as long as they also share a sheet.

uniformsoptionalTUniformValues

This sprite's own values for its material's uniforms, laid over the material's every frame.

What it buys: fifteen sprites, one compiled effect, fifteen different settings of it. Without it, varying one number would mean a material apiece, and a material apiece is a compile of the identical shader apiece.

The cost is a draw of its own: its numbers are written per run, so a sprite with its own set cannot share one. Fifteen is nothing; a thousand would be worth knowing about.

zIndexoptionalnumber

Draw order within its scene: higher on top, ties in creation order. Omitted counts as 0, and a scene where no sprite says it is not sorted at all.

destroyedboolean

Set by destroy, on it or on the object it belongs to, and never cleared. True means it is on its way out and nothing should treat it as part of the game any more, even in the gap before the frame sweeps it away.

View source · gameobjects/sprite/types/t_sprite.ts:9

TTexttypenacatamalon

A text in the scene, as createText gives it back: a string drawn with a bitmap or a vector font. Plain data; change any field (text above all) and the next frame shows it.

Properties

idstring
type'text'
textstring

What it says. \n starts a new line.

fontTBitmapFont | TFont

A bitmap font (useLoadBitmapFont) or a vector one (useLoadFont). Can be swapped for another of either kind at any time.

styleTTextStyle

Size, alignment and spacing. Held by reference, so a shared style changes every text using it.

tintTColor
transform{ x, y, rotation, scaleX, scaleY }

Where the block is. Scale and rotation apply to the whole block, around its anchor.

worldTransformoptional{ x, y, rotation, scaleX, scaleY }

Where it ends up once everything above it has moved it, worked out once a frame while the tree is walked. Left off when nothing above it has a placement of its own, which is the ordinary case: then its own transform is already where it is.

Set by the engine every frame and never authored or saved. Ask worldOf rather than reading either field by hand.

anchoroptional{ x, y }

Which point of the block sits on its transform, in 0-1. Omitted is its top-left corner.

pivotoptional{ x, y }

The point of the block it turns and grows about, in 0-1 like anchor, when that is not its anchor: a score placed by its left edge that pops bigger from its middle. Unturned and ungrown it sits as its anchor says; turned, it turns about this point, anchor and all. Omitted is its anchor. Can be changed at any moment, and taken away (undefined).

zIndexoptionalnumber

Draw order within its scene, as for a sprite. The whole text moves as one.

smoothoptionalboolean

Crisp or blended when scaled. Omitted, the game's smooth decides.

parallaxoptional{ x, y }

How much it moves with the camera, as for a sprite: 1 (the default) as everything else, 0 not at all. Ignored on what is pinned to the screen. Can be changed any frame.

blendoptional'alpha' | 'additive'

'additive' adds its colour to what is behind it, so it can only brighten; 'alpha' (the default) covers it. Can be changed any frame.

tagsoptionalstring[]

What it is, for something drawn on its own rather than a piece: ['wall']. What useTag adds and finds, and what collisions are asked by. Absent is none.

visibleoptionalboolean

Whether it is drawn at all. Omitted is drawn. Hidden, it keeps what it says and costs nothing to show again, which is what a label that comes and goes wants.

materialoptionalTSpriteMaterial

An effect of its own, from createMaterial. Omitted is the built-in shader.

It is carried by every letter, and every letter carries the same one, so a title with an effect on it is still one draw rather than one draw per character.

uniformsoptionalTUniformValues

This text's own values for that material's uniforms, laid over the material's own.

destroyedboolean

Set by destroy, on it or on the object it belongs to, and never cleared.

View source · gameobjects/text/types/t_text.ts:13

TTextOptionstypenacatamalon

TTextOptions: T2dOptions & { text, font, style }

What createText is asked for.

Properties

textstring

What it says. \n starts a new line.

fontoptionalTBitmapFont | TFont | string

A font from useLoadFont (a .ttf or .woff, sharp at any size) or useLoadBitmapFont (a picture of the letters, crisp at whole multiples of its height), or the key it was loaded under in this scene or any earlier one: one scene loads the game's fonts and the others name them, font: 'title'. A key nothing was loaded under throws, naming it. Left out, the engine's own: Nacatamal Arcade, an 8 px arcade font with lowercase, accents and the Spanish ñ, ¿ and ¡, carried inside the engine so nothing has to be loaded. 'nacatamalon:square' and 'nacatamalon:thin' name the other two it carries.

styleoptionalTTextStyle

Size, alignment and spacing. Kept as given, not copied: pass the same object to several texts and changing it changes all of them. For one text of its own, spread it: { ...heading, fontSize: 24 }.

transformoptionalPartial<TTransform2d>

Where it is, how it is turned and how big. Only what is given: the rest is no turn and a scale of 1, so { x, y } is enough. Copied, so the object handed in stays the caller's.

anchoroptional{ x, y }

Which point of it sits on its transform, in 0-1 of its own size: { x: 0.5, y: 0.5 } is its middle, { x: 0.5, y: 1 } the middle of its bottom edge (a character standing on a floor), { x: 0, y: 0 } its top-left corner. Rotation and scale happen around it, unless pivot says another point. Default: the middle for a sprite and a panel, the top-left corner for a text.

They differ on purpose. A thing of the world sits by its middle, the point it turns and grows on; a text sits by its corner so it grows without moving, and a score going from 9 to 10 does not shift. A label centred on a panel gives them both the same anchor.

pivotoptional{ x, y }

The point it turns and grows about, in 0-1 of its own size, when it is not the anchor: the anchor decides where it sits, the pivot what it spins on. A door anchored at its corner turns on its hinge ({ x: 0, y: 0.5 }); a score anchored at its left edge pops bigger from its middle ({ x: 0.5, y: 0.5 }). Default: its anchor.

tintoptionalTColorOption

Its colour, multiplied over what it draws: '#ff6b1a', 0xff6b1a, 'tomato' or a TColor. Default white, drawn as it is. A TColor is copied, so changing this one's tint changes no other thing given the same colour.

visibleoptionalboolean

Whether it is drawn. Default true. false makes it hidden from the start, which is how a set of them is prepared in advance and shown one at a time.

zIndexoptionalnumber

Which others it is drawn in front of, within its own scene: higher numbers go on top, and negatives are allowed. The same number keeps the order they were made in. Default 0. It can be changed at any time and takes effect on the next frame drawn.

smoothoptionalboolean

Crisp (false) or blended (true) when scaled: false keeps pixel art crisp. Default: the game's smooth.

parallaxoptional{ x, y }

How much it moves with the camera: 1 (the default) as everything else, 0 not at all, and in between further away: { x: 0.3, y: 0 } is a far range of mountains that slides slowly by and keeps its height. Only how it is drawn and touched by the pointer: its placement stays what it says. Something pinned to the screen (useScreenSpace, a HUD) does not see the camera, so it has no parallax whatever this says.

blendoptional'alpha' | 'additive'

How it lands on what is behind it. 'alpha' (the default) covers it as far as its alpha says. 'additive' adds its colour instead, so it can only brighten: a halo, a flash, a glowing "LEVEL UP!", a lamp at night. Two additive things over each other are brighter than one. Can be changed any frame.

tagsoptionalstring[]

What it is, as useTag says it: ['wall']. The same as adding them after.

materialoptionalTSpriteMaterial

An effect of its own, from createMaterial. Omitted is the built-in shader.

uniformsoptionalTUniformValues

Its own values for that material's uniforms, laid over the material's own.

onPointerOveroptionalTPointerListener

The pointer comes over the sprite.

onPointerOutoptionalTPointerListener

The pointer stops being over it, or leaves the game.

onPointerMoveoptionalTPointerListener

The pointer moves while over it.

onPointerDownoptionalTPointerListener

A button is pressed, or a finger touches, over it.

onPointerUpoptionalTPointerListener

A button is released, or a finger lifts, over it.

onClickoptionalTPointerListener

Pressed and released without leaving it. The cursor turns into a hand over it.

onDragStartoptionalTPointerDragListener

Pressed with the main button (or a finger) and moved far enough not to be a click: a few pixels of the page, more for a finger, which shakes. Once it starts, the press is a drag and not a click: letting go over it does not call onClick. The cursor turns into an open hand over something that can be dragged, and a closed one while it is.

Nothing moves by itself: the events say what the pointer did, and the game decides what that does (follow it, pull a slingshot back, turn a dial). useDraggable is the one that moves it.

onDragoptionalTPointerDragListener

The pointer that started the drag moved, wherever it is: over the sprite or not, in the game or off its edge. Called right after onDragStart too, so the first move is not lost.

onDragEndoptionalTPointerDragListener

The pointer that dragged it let go, with target and hits saying what it was let go over.

View source · gameobjects/text/types/t_text_options.ts:12

TTextStyletypenacatamalon

How a text is set: size, alignment and spacing. Kept apart from the rest of a text so it can be shared: several texts given the same style change together when it changes.

Properties

fontSizeoptionalnumber

How big the letters are, in pixels.

For a vector font (useLoadFont), the size of the font as anywhere else type is set: one em is this many pixels, and the line is as tall as the font says. Default 16. Any size is sharp.

For a bitmap font, how tall one line is. Default: the font's own height, so the font as drawn. A pixel font looks crisp at whole multiples of its height (16 or 24 for an 8 pixel font) and uneven in between.

alignoptional'left' | 'center' | 'right'

Where each line sits: inside maxWidth when there is one, inside the width of the longest line when not. Default 'left'.

maxWidthoptionalnumber

How wide a line can be, in pixels, before its words go on to the next one: a dialogue box, a panel's description. The text's block is this wide, so align and anchor place the lines in the box rather than around the words. Measured before the text's scale, like the other sizes here.

Lines break at spaces; a word wider than the whole width breaks between two letters. \n still starts a line wherever it is. Changing the text or the size breaks it again on the next frame. Left out or 0, lines are only broken by \n.

letterSpacingoptionalnumber

Extra pixels between two characters. Default 0.

lineSpacingoptionalnumber

Extra pixels between two lines. Default 0.

View source · gameobjects/text/types/t_text_style.ts:9

TTransform2dtypenacatamalon

Where a game object is, how it is turned and how big it is drawn.

Every field is required and written out, rotation: 0, scaleX: 1, scaleY: 1 included. Spelled out rather than filled in from a default, so a transform read from a file, one built by hand and one the editor wrote are the same five numbers, and moving one never depends on which of the three it came from.

That is the object once made. Making one takes only the fields that differ from the defaults (createSprite({ transform: { x: 40, y: 112 } })), and the rest are filled in there.

Properties

xnumber
ynumber
rotationnumber
scaleXnumber
scaleYnumber
View source · gameobjects/types/t_transform_2d.ts:16

TTransform3dtypenacatamalon

TTransform3d: TTransform2d & { z, rotationX, rotationY, scaleZ, quaternion, pivot }

Where something is in three dimensions, how it is turned and how big it is drawn.

The 2D transform is exactly its flat half, with the same names: x, y, rotation (the turn in the plane, around Z) and scaleX/scaleY mean here what they mean there. That is what lets one box hold a 2D game, a 3D one, or both, without a second kind of placement to learn.

Rotations are in radians and applied Y, then X, then Z, and the whole is move, then turn, then scale. Written out rather than filled in from defaults, for the reason TTransform2d gives.

Which way each turns, with y up, x to the right and z towards the viewer, as a camera that is not turned sees them, looking along -z:

  • rotationY turns to the left as seen from above: a quarter, Math.PI / 2, takes +x to -z, and what looked along -z then looks along -x.
  • rotationX looks up: a quarter takes what looked along -z to +y, and +y to +z.
  • rotation turns about z, against the clock as the viewer sees it: a quarter takes +x to +y. The same number turns a sprite with the clock, because in 2D y grows down.

Y first, so rotationX looks up and down from wherever rotationY has turned to, and rotation rolls about the way it then faces.

A quaternion is the other way to say which way something is turned, and when one is set it is the one that counts. Three angles cannot express every turn on their way to it: at certain facings two of the three end up turning around the same line and one of them stops doing anything, which is why a ship that is free to point anywhere, or a turn being eased from one facing to another, is stored this way instead.

Properties

znumber

Towards the viewer.

rotationXnumber

Looking up and down, in radians: more looks up, what faced -z tipping towards +y.

rotationYnumber

Turning left and right, in radians: more turns to the left as seen from above, +x towards -z.

scaleZnumber
quaternionoptionalTQuat | null

Which way it is turned, as a whole. Set, it decides the turn and the three angles above are ignored; left out, the three angles decide it as they always did.

It only speaks for three dimensions. Anything flat inside this one, a picture or a piece of writing, is still turned by rotation, because there is no such thing as half of a turn in space taken flat.

pivotoptional{ x, y, z } | null

The point it turns and grows about, in its own units from its origin, when that is not the origin: a model's feet, { x: 0, y: -1, z: 0 }, for one that stumbles forward over them; a door's hinge. Left out, it turns about its origin as it always did.

Setting it does not move anything: unturned and at its own size, every point of it is where it was. Only a turn or a growth then goes about the pivot, the way a sprite's pivot does in the plane, and what it holds turns and grows about it too.

It only speaks for three dimensions, as quaternion does: a picture or a piece of writing inside this one, and a light, still turn about the origin, by rotation.

xnumber
ynumber
rotationnumber
scaleXnumber
scaleYnumber
View source · gameobjects/types/t_transform_3d.ts:36

TViewFiltertypenacatamalon

Which part of the world a view (sees: 'world') takes in, or leaves out: by tags (an object's, TBox.tags, or a sprite's, text's or panel's own), by kind of drawing, or by naming objects.

The three add up: { tags: ['terrain'], objects: [player] } is the terrain and the player. A tag or a named object takes everything under it as well. As a view's hide it leaves what matches out, and as its only it takes in nothing else; hide wins wherever the two meet. Neither reaches what the view draws itself, and neither brings back what is hidden (visible: false), which no view shows. A mask's shape left out still cuts what the view does draw, as it does on the screen.

Properties

tagsoptionaltypeOperator

Objects carrying any of these tags, and everything under them, and sprites, texts and panels carrying one themselves (useTag(name).add(sprite)).

kindsoptionaltypeOperator

Drawings of these kinds: 'sprite', 'text', 'nine-slice', 'tilemap', 'particles', 'particles-3d', 'mesh', 'lines', 'polygon', 'shapes', and 'custom' for the drawings of every kind a plugin registered.

objectsoptionalReadonlyArray<TBox | TDrawable>

These objects and everything under them, or these drawings. In code only: an object cannot be written into a scene document, so a saved view keeps its tags and kinds and not these, and saving it says so.

View source · gameobjects/sprite_texture/types/t_sprite_texture.ts:30

TViewOptionstypenacatamalon

TViewOptions: Omit<TSpriteTextureOptions, 'sees'> & { x, y }

What createView is asked for: where on the screen the view goes, and the rest as for a view of the world made with createSpriteTexture (its size, what is behind it, what of the world it takes in).

Properties

xnumber

Its left edge, in screen pixels: from the left of the game when it is made in the scene's body, and from where the piece it is made in is placed otherwise.

ynumber

Its top edge, in screen pixels, measured as x is.

View source · gameobjects/sprite_texture/types/t_view_options.ts:12

TViewPointInputtypenacatamalon

TViewPointInput: { x, y } | TPointerInfo

A point given to the view's coordinates: one in the place of the sprite showing the view (the world of its scene, or the game's screen pixels when the sprite is pinned to the screen), or what the pointer said, from which the right one of those is taken.

View source · gameobjects/sprite_texture/view_coordinates.ts:31

TViewToWorldtypenacatamalon

Where a point on the sprite showing a view lands in the world the view sees.

Properties

xnumber

The point of the world the view sees, in its 2D world.

ynumber
insideboolean

Whether the point is on the part of the picture the sprite shows. Outside, x and y still say where it would be, as if the picture went on. A mask over the sprite is not counted: it is drawing, not a shape. For a round minimap, measure from picture to its middle.

picture{ x, y }

The same point in the picture's pixels, from its top-left corner.

View source · gameobjects/sprite_texture/view_coordinates.ts:40

TWorldToViewtypenacatamalon

Where a point of the world a view sees lands on the sprite showing it.

Properties

xnumber

Where it lands, in the sprite's place: the world of its scene, or the screen's pixels for a sprite pinned to the screen. Off the sprite too.

ynumber
insideboolean

Whether it is on the part of the picture the sprite shows.

edge{ x, y }

The point of the sprite's edge in the direction of the point, seen from the sprite's middle: the point itself when it is inside. Where an arrow at the edge of a minimap goes.

View source · gameobjects/sprite_texture/view_coordinates.ts:65