Sprites
Back to the reference

Sprites

The 2D drawable and its atlas.

25 symbols

createBackdropfunctionnacatamalon

createBackdrop(options: TBackdropOptions) => TSprite

A strip of picture that repeats endlessly across the world and moves with the camera only so much: the far layers of a platformer, clouds, hills, a city skyline, as the 16-bit consoles drew them.

One sprite, laid far wider than any level and repeated, with parallax: nothing to move every frame, and it is there wherever the camera goes. It moves in whole pixels.

Parameters

optionsTBackdropOptions

The picture, its parallax, and where its top is.

Example

export const Level: TSceneFn = () => {
    useLoadTexture({ src: '/backdrops/clouds.png', key: 'clouds' });
    useLoadTexture({ src: '/backdrops/hills.png', key: 'hills' });
    createBackdrop({ key: 'clouds', parallax: { x: 0.1, y: 0 }, y: 20 });
    createBackdrop({ key: 'hills', parallax: { x: 0.4, y: 0.2 }, y: 120 });
    return createScene();
};
View source · gameobjects/sprite/create_backdrop.ts:66

createMode7functionnacatamalon

createMode7(options: TMode7Options) => TMode7

A floor seen in perspective that turns and stretches as the camera moves over it, the Mode 7 of the 16-bit consoles: the track of a kart racer, the world map seen from the air, the arena that spins under a boss.

One sprite as large as the screen, or as the view it is made in, whose picture is the map seen from above. A material works out, for every pixel below the horizon, the point of the map it is looking at; above the horizon nothing is drawn, so a createBackdrop behind it is the sky.

The camera is the floor's uniforms (x, y, angle, height…), in pixels of the map. Things standing on the floor (trees, coins, the other karts) are ordinary sprites put where the floor shows them with placeOnMode7, and screenToMode7 turns a click into a point of the map.

The scene it is in needs no camera of its own: the floor is its camera. It is drawn from the top left of where it is made, and fills what it is made on with the size that has when it is made.

Parameters

optionsTMode7Options

The map, how it is first looked at, what is past its edges and the haze.

Example

export const Race: TSceneFn = () => {
    useLoadTexture({ src: '/maps/track.png', key: 'track' });
    createBackdrop({ key: 'hills', parallax: { x: 0, y: 0 }, y: 40 });
    const floor = createMode7({ key: 'track', horizon: 76, height: 24, x: 512, y: 900 });
    const tree = createSprite({ key: 'tree', anchor: { x: 0.5, y: 1 } });
    const keys = useKeyboard();

    useUpdate((delta) => {
        if (keys.isDown('ArrowLeft')) floor.uniforms.angle -= delta * 2;
        if (keys.isDown('ArrowRight')) floor.uniforms.angle += delta * 2;
        if (keys.isDown('ArrowUp')) {
            floor.uniforms.x += Math.sin(floor.uniforms.angle) * delta * 200;
            floor.uniforms.y -= Math.cos(floor.uniforms.angle) * delta * 200;
        }
        placeOnMode7(floor, tree, 540, 700);
    });

    return createScene();
};
View source · gameobjects/sprite/create_mode7.ts:210

createSpritevariablenacatamalon

createSprite: TCreateSprite

Puts a picture in the scene: an image from useLoadTexture, a frame of a sheet, or a plain coloured rectangle when it has neither.

It is placed by its anchor, its middle unless you say otherwise, so transform: { x: 160, y: 120 } centres it there. Everything about it is a plain field you can change at any time (hero.transform.x += 1, hero.tint = red), and the next frame shows it.

Example

export const Level: TSceneFn = () => {
    const texture = useLoadTexture({ src: '/assets/hero.png' });
    const hero = createSprite({ texture, transform: { x: 160, y: 120 } });
    // No picture: a coloured rectangle, placed by its top-left corner.
    createSprite({ width: 320, height: 16, tint: '#3a2a1a', anchor: { x: 0, y: 0 }, transform: { y: 224 } });

    useUpdate((delta) => {
        hero.transform.rotation += delta;
    });

    return createScene();
};
View source · gameobjects/sprite/create_sprite.ts:153

mode7ToScreenfunctionnacatamalon

mode7ToScreen(floor: TMode7, x: number, y: number) => TMode7Point | null

Where a point of the map is seen on the floor, and how large: the floor's own arithmetic run the other way, on the CPU. null when the point is behind the camera, where nothing of the floor is.

A point well ahead but off to the side still has a place, off the floor's edges; a point very far ahead lands just under the horizon, very small.

Parameters

floorTMode7

The floor, from createMode7.

xnumber

Across the map, in its pixels.

ynumber

Down the map, in its pixels.

View source · gameobjects/sprite/mode7_points.ts:85

placeOnMode7functionnacatamalon

placeOnMode7(floor: TMode7, sprite: TSprite, x: number, y: number) => boolean

Stands a sprite on a point of the map: puts it where the floor shows that point, scales it by how far away it is, orders it with the rest by distance and hides it when it is behind the camera or off the floor. Called every frame for whatever stands on the floor, since the camera moves.

The sprite's own size is its size on the map, in the map's pixels, and its anchor is the point that stands on it: { x: 0.5, y: 1 }, the middle of its feet, is what a tree or a kart wants.

It writes the sprite's transform (x, y, scaleX, scaleY), its zIndex and its visible. The zIndex it writes is between -1 and 0, the nearer the higher: in front of the floor, behind anything at 0 or more, which is where the player's own kart and the HUD go.

Parameters

floorTMode7

The floor, from createMode7.

spriteTSprite

What stands there.

xnumber

Across the map, in its pixels.

ynumber

Down the map, in its pixels.

View source · gameobjects/sprite/mode7_points.ts:159

screenToMode7functionnacatamalon

screenToMode7(floor: TMode7, x: number, y: number) => { x, y } | null

The point of the map a point of the floor shows: a click on the track turned into where on the track it is. null above the horizon, where there is no floor, and outside the floor.

Parameters

floorTMode7

The floor, from createMode7.

xnumber

Across, measured as the floor is (the screen's pixels in a scene without a camera).

ynumber

Down, measured the same way.

View source · gameobjects/sprite/mode7_points.ts:119

TAtlasPointtypenacatamalon

A place on a frame: its pixels from the frame's top-left corner, measured as anchor is, so { x: 14, y: 10 } is the top-left corner of that pixel. It may be outside the frame.

Properties

xnumber
ynumber
View source · atlas/types/t_sprite_atlas.ts:53

TBackdropOptionstypenacatamalon

TBackdropOptions: Pick<TSpriteOptions, 'key' | 'texture' | 'atlas' | 'frame' | 'tint' | 'smooth'> & { parallax, y, height, tileY, zIndex }

What a backdrop shows and where.

Properties

parallax{ x, y }

How much it moves with the camera: { x: 0.2, y: 0 }, clouds far away that slide slowly by.

yoptionalnumber

Where its top is, in the world: with parallax.y at 0, where it sits on the screen. 0 by default.

heightoptionalnumber

How tall it is. Its picture's height by default; with tileY, ignored.

tileYoptionalboolean

Repeats down as well as across, filling everything: a sky, a cave wall. false by default.

zIndexoptionalnumber

Where it is drawn among the rest. Behind everything by default.

View source · gameobjects/sprite/create_backdrop.ts:17

TCreateSpritetypenacatamalon

TCreateSprite: (options: { transform, anchor, pivot, tint, visible, zIndex, smooth, parallax, blend, tags, material, uniforms } & TSpriteEvents & { width, height, texture, key, atlas, frame, uvOffset, uvScale, flipX, flipY, tile, tileOffset } & { width, height }) => TSprite & { width, height }

The two ways to call createSprite. Given a width and a height (a coloured rectangle, or a picture drawn at a size of its own), the sprite that comes back has them as numbers, so paddle.width can be used in sums straight away. Given neither, they stay optional: the size is the picture's, and it is not known until the picture has loaded.

View source · gameobjects/sprite/create_sprite.ts:71

TMode7typenacatamalon

TMode7: TSprite & { uniforms }

A Mode 7 floor: a sprite, whose uniforms are where it is looked at from.

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/create_mode7.ts:90

TMode7Optionstypenacatamalon

TMode7Options: Pick<TSpriteOptions, 'key' | 'texture' | 'smooth'> & { x, y, angle, height, horizon, fov, outside, haze, zIndex }

What a Mode 7 floor shows and how it is first looked at. Everything but the picture can be changed afterwards in the floor's uniforms.

Properties

xoptionalnumber

Where the camera starts, across the map. 0 by default.

yoptionalnumber

Where the camera starts, down the map. 0 by default.

angleoptionalnumber

Which way it starts looking. 0, up the map, by default.

heightoptionalnumber

How high above the floor the camera is, in pixels of the map. 32 by default.

horizonoptionalnumber

The row of the horizon, in pixels from the top. A third of the way down by default.

fovoptionalnumber

How wide the view opens, in degrees, and so how deep the floor looks (see TMode7View.fov). 45 by default.

outsideoptional'repeat' | TColorOption

What is past the edges of the map: 'repeat', the default, carries on with the map itself; a colour shows that colour, and a transparent one whatever is behind the floor.

hazeoptional{ color, from, to }

The far floor fading into a colour, from from pixels ahead until it is all colour at to: a distance of its own, and what hides the shimmer of hard pixels that far away. None by default.

zIndexoptionalnumber

Where it is drawn among the rest. Behind what is placed on it and in front of the backdrops by default (-5000).

View source · gameobjects/sprite/create_mode7.ts:100

TMode7Pointtypenacatamalon

Where a point of a Mode 7 map is seen on its floor.

Properties

xnumber

Across, in the floor's own place: where its sprite is measured from, the screen's pixels in a scene without a camera.

ynumber

Down, measured the same way.

scalenumber

How many pixels of the screen a pixel of the map is there: what something standing on that point is scaled by.

depthnumber

How far ahead of the camera the point is, in pixels of the map: the larger, the further.

View source · gameobjects/sprite/mode7_points.ts:11

TMode7Viewtypenacatamalon

Where a Mode 7 floor is looked at from, and how it looks: the numbers its picture is drawn with. They are the floor's uniforms, so writing one is what moves the floor on the next frame: floor.uniforms.angle += 0.1.

Distances are in the pixels of the floor's picture, the map: a kart at x: 300 is 300 pixels of the map across, the same numbers tileAt and the physics read.

Properties

xnumber

Where the camera stands on the map, across.

ynumber

Where the camera stands on the map, down.

anglenumber

Which way it looks, in radians, as a 2D turn is measured: 0 looks up the map, and it grows clockwise, so Math.PI / 2 looks to the right of it.

heightnumber

How high above the floor the camera is, in pixels of the map. Lower is faster-looking and flatter; higher sees more of the map at once, the view of a world map.

horizonnumber

The row of the floor where the horizon is, in pixels from its top. Nothing is drawn above it.

size{ x, y }

The floor's own size, in pixels, which the view is worked out in: the size it was made with. The shader and placeOnMode7 both read it, so they agree whatever the screen does afterwards; changing the sprite's width or height stretches the floor and what stands on it alike.

fovnumber

How wide the view opens from side to side, in degrees. It is also how deep the floor looks from top to bottom, since the screen is one picture seen through one eye: a wider view brings every point of the map nearer the horizon and makes it smaller. So changing it moves whatever stands on the floor; what placeOnMode7 places follows, and a sprite put on the screen by hand (a kart always at the bottom) has to be put again, or it shows another point of the map.

repeatnumber

1 repeats the map past its edges, 0 shows outside there. Set by the outside option.

outsideTColor

What is past the edges of the map when it does not repeat. Transparent shows what is behind.

hazeColorTColor

The colour the far floor fades into. Its alpha is how much it fades in the end.

hazeFromnumber

How far ahead the haze starts, in pixels of the map.

hazeTonumber

How far ahead it is complete. No haze while this is not past hazeFrom.

View source · gameobjects/sprite/create_mode7.ts:24

TSpriteOptionstypenacatamalon

TSpriteOptions: T2dOptions & { width, height, texture, key, atlas, frame, uvOffset, uvScale, flipX, flipY, tile, tileOffset }

What createSprite is asked for: a picture (texture, key or atlas), its size, where it goes and how it looks. All of it is optional.

Properties

widthoptionalnumber

Omitted, it is drawn as wide as what it shows of its texture, and the sprite's width stays undefined.

heightoptionalnumber

Omitted, it is drawn as tall as what it shows of its texture, and the sprite's height stays undefined.

textureoptionalTTexture | string

Its picture: a texture from useLoadTexture, or the key it was loaded under ('hero'), the way a text names its font. Wins over key.

keyoptionalstring

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

atlasoptionalTSpriteAtlas

A sheet from createSpriteAtlas. It supplies the image and, with frame, which part of it to show. Anything given explicitly (texture, uvOffset, uvScale) wins over it.

frameoptionalnumber

Which frame of atlas to show, numbered from 0. Ignored without an atlas. Default 0.

uvOffsetoptional{ x, y }

Shows only part of the texture: where the window starts, in 0-1 across the image. Comes with uvScale, and both together are how one image holds many frames.

uvScaleoptional{ x, y }

How big that window is, in 0-1: { x: 0.5, y: 1 } is half the width, full height.

flipXoptionalboolean

Shows the picture mirrored left to right, which is how one drawing covers a character facing either way. It mirrors what is shown and not where it is: the sprite stays exactly where it was, and so does the place it can be touched. A text or a panel, made of pieces, is mirrored as a whole with transform: { scaleX: -1 } instead.

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.

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/sprite/types/t_sprite_options.ts:13

TSpriteTexturetypenacatamalon

A picture that part of a scene is drawn into instead of the screen: a screen inside the game, a monitor, a handheld's display.

It sits on the object whose contents it shows. Everything on that object and under it is drawn into texture every frame, in the picture's own pixels, and anything else can show texture the way it shows a loaded image. The object is where the picture's world ends: a camera asked for in there belongs to the picture, and a lamp in there lights only the picture.

Plain data like every record, apart from texture.gpu, which is the renderer's.

Properties

type'sprite-texture'
idstring
widthnumber

In pixels. Also how wide the world inside is, before any camera.

heightnumber

In pixels. Also how tall the world inside is, before any camera.

seesTSpriteTextureSees

What is drawn into it. 'inside': only what is on its object and under it, a world of its own. '3d': the models of the world around it as well, seen from its own camera, which is a security camera and a monitor showing it. 'world': the whole world of its scene, its sprites, maps, texts, particles and models, through its own cameras: a minimap, a mirror, half of a split screen. What is on its object is drawn either way, on top: sees says only what comes in from outside.

hideTViewFilter | null

What a view ('world') leaves out of the world it sees, or null. Changed with setViewFilter.

onlyTViewFilter | null

What alone a view ('world') takes in of the world it sees, or null for all of it.

backgroundTColor

What the picture is cleared to every frame, behind everything drawn into it.

textureTTexture

The picture itself, ready from the first frame and found in the game's textures by its key.

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

TSpriteTextureOptionstypenacatamalon

What createSpriteTexture is asked for.

Properties

widthnumber

In pixels, rounded down and at least 1.

heightnumber

In pixels, rounded down and at least 1.

seesoptionalTSpriteTextureSees

'inside', the default: only what the component draws, a world of its own. '3d': the models and particles in depth of the world around it as well, seen from the component's own 3D camera (or the scene's, if it asks for none) and lit by the scene's lamps, with whatever the component draws on top. That is a security camera: the flat part of the scene, its sprites and its texts, is not in the room and is not seen.

'world': a view of the whole world of its scene, drawn again through the component's own cameras (or the scene's, where it asks for none) and not run a second time: a minimap, a mirror, half of a split screen. Its 2D camera sees the sprites, maps, texts and particles, each placed for it, parallax included; its 3D camera sees the models, and one that follows the 2D (follow2d) follows the view's. What is pinned to the screen (useScreenSpace) is the screen's and is never in a view, and neither is anything showing the view itself. What the component draws goes on top, and is seen only there: a minimap's marker. It is in the world the view looks at, through the same cameras, lit by the scene's lamps and in its fog, unless the view brings lamps or fog of its own. A useAmbientLight of its own is not a lamp: it keeps the scene's and sets how dark the shade is in all the view shows, the world too, like its fog (a minimap of a dark dungeon at intensity: 1 reads in full). In a picture that sees '3d' it sets the level of the room the picture shows. A picture that sees 'inside' is a world of its own and is lit only by what is in it.

hideoptionalTViewFilter

For a view ('world'): what of the world it leaves out. hide wins over only.

onlyoptionalTViewFilter

For a view ('world'): what alone of the world it takes in.

backgroundoptionalTColorOption

What is behind everything drawn into it. Opaque black when left out. A transparent one lets whatever shows the picture be seen through the parts nothing covers.

keyoptionalstring

The name the picture is kept under, so a model can ask for it by name the way it asks for a loaded image. A new one of its own when left out.

Worth giving in a scene that restarts: the same name and size gets the same picture back instead of a new one each time.

View source · gameobjects/sprite_texture/types/t_sprite_texture_options.ts:11

nacatamalon/files

parseAtlasDocfunctionnacatamalon/files

parseAtlasDoc(value: unknown, src: string) => TAtlasDoc

Reads an .atlas file, already parsed from JSON, and checks all of it at once.

All of it and at once, rather than whatever a sprite happens to touch, because tools read these files as much as games do: an editor has to say "this file is broken, here" while its author is looking at it. Every message names src, since a project has many sheets and this is the last place that knows which one it was.

Parameters

valueunknown

The file's contents, parsed from JSON.

srcstring

Where it came from, for the messages.

View source · atlas/document/parse_atlas_doc.ts:68

TAtlasDoctypenacatamalon/files

What an .atlas file holds: which image, how it is cut, and the named runs its frames make.

Cut one of two ways and never both: a regular grid, or a packed table of rectangles, which is what a packing tool writes.

Properties

formatnumber
kind'atlas'
texturestring

The image, relative to the .atlas file.

gridoptionalTAtlasGridSpec
packedoptionalRecord<string, TAtlasPixelRect>

Frame name to rectangle, in the order the frames are numbered.

sequencesoptionalRecord<string, TAtlasSequenceDoc>
pointsoptionalRecord<string, Record<string, { x, y }>>

Named points of its frames, for pointOf, by the frame's number, or its name in a packed sheet: { "4": { "hand": { "x": 14, "y": 10 } } }, in the frame's pixels from its top-left corner. A new optional field: an older reader goes on as if it were not there.

View source · atlas/document/types/t_atlas_doc.ts:104

TAtlasDocFrametypenacatamalon/files

One frame of a sheet as a document cuts it: the window into the image in 0-1, and its size in pixels, with its name when the sheet is packed.

Properties

nameoptionalstring
uvOffset{ x, y }
uvScale{ x, y }
widthnumber
heightnumber
View source · atlas/document/types/t_atlas_doc.ts:133

TAtlasGridSpectypenacatamalon/files

How a sheet laid out in a regular grid is cut: the size of a cell, or how many there are, and the gaps round and between them.

Give the cell size or the count on each axis, and the other is worked out from the image. That is what lets the same file describe a sheet whose size is not a whole number of cells, a common thing in sheets made by hand: whatever is left over at the edge is simply not a frame.

Properties

frameWidthoptionalnumber

Width of one cell in pixels.

frameHeightoptionalnumber

Height of one cell in pixels.

columnsoptionalnumber

Cells across. Worked out from the image when left out.

rowsoptionalnumber

Cells down. Worked out from the image when left out.

marginoptionalnumber

Empty pixels round the whole sheet. Default 0.

spacingoptionalnumber

Empty pixels between two cells. Default 0.

countoptionalnumber

How many cells are frames, counting row by row, for a last row that is not full.

View source · atlas/document/types/t_atlas_doc.ts:13

TAtlasSequenceDoctypenacatamalon/files

A named run of frames: which ones, how fast, and what comes after.

Properties

framesnumber | string[]

The frames to play in order: numbers in a grid, names in a packed sheet, mixed freely. Repeats are allowed.

fpsoptionalnumber

Frames per second. Default 12.

loopoptionalboolean

Starts again at the end. Default true; false rests on the last frame.

repeatoptionalnumber

How many extra times it runs after the first: 2 is three times, then it ends. Given, it decides. A negative one, which older files have, is for ever. As a tween's repeat.

yoyooptionalboolean

Each time it runs again it comes back the other way, the ends shown once. As a tween's yoyo.

nextoptionalstring

The run to play when this one ends: a punch that drops back to standing. Only means something for a run that ends (loop: false, or a repeat), since one that loops never does.

In the file and not in the script that starts the punch, because what follows a punch is a decision about the animation, and one written into code makes retiming a character a code change. A name no run answers to is said once and the run rests on its last frame.

View source · atlas/document/types/t_atlas_doc.ts:60