Skip to content

Code reference

Every command your game code can use. It comes from the same list the editor uses for its suggestions, so if it's here, it works in your game.

The words on this page are quite technical. Don't worry: the editor shows the same help while you type, and the lessons explain the commands you need.

Ready to use

Things you can use anywhere in your code, like Input for the keyboard or Time for the clock.

BlendModeglobal 4 commands
const BlendMode

How a SpriteRenderer or ParticleSystemRenderer meets what is drawn already (blendMode).

readonly Alpha: 0;

Normal transparency (the default).

readonly Additive: 1;

Adds its colour to the background: glows, fire, light beams.

readonly Multiply: 2;

Multiplies the background: shadows, tinting.

readonly Screen: 3;

Lightens the background without clipping to white.

Cameraglobal 1 command
const Camera

All scene cameras at once (the component type is Camera too: this is its value side).

Shake(amplitude: number, seconds: number): void;

Shakes every scene camera by up to amplitude world units, fading over seconds, while playing.

ColliderFilterglobal 5 commands
const ColliderFilter

Collision categories, combined as a bit mask, for a collider's filter (BoxCollider / CircleCollider SetFilter, Physics query filters, GameObject.HasColliderFilter). Never for a GameObject's own filter: that is its render layers, and these bits mean other things there (Enemy is MaskLayerFilter.UI: a GameObject given it is drawn by a UI camera).

readonly Player: number;
readonly Enemy: number;
readonly Object: number;
readonly Background: number;
readonly UI: number;
ComponentTypeglobal 30 commands
const ComponentType: NComponentTypeMap

Every component a GameObject can carry. The values are persisted in saved scenes, so they are frozen — see WEEnumComponent. Each member is typed as its literal value, which is what lets GetComponent(ComponentType.BoxCollider) return a BoxCollider rather than a bare Component.

readonly Transform: 0;
readonly SpriteRenderer: 1;
readonly AnimationRenderer: 2;

Sprite Animation: frame clips on the SpriteRenderer.

readonly BoxCollider: 3;
readonly CircleCollider: 4;
readonly PolygonCollider: 5;

@deprecated Not implemented: AddComponent with it throws. The value is kept for saved scenes.

readonly ParticleSystemRenderer: 6;

Particle System: an emitter drawn in one batch.

readonly SpriteBatch: 7;

@deprecated Not implemented: AddComponent with it throws. The value is kept for saved scenes.

readonly AudioSource: 8;
readonly Material: 9;
readonly Shader: 10;

@deprecated Not implemented: AddComponent with it throws. The value is kept for saved scenes.

readonly Script: 11;
readonly SpineRenderer: 12;
readonly TileRenderer: 13;
readonly MeshRenderer: 14;
readonly BitmapText: 15;
readonly Animator: 16;
readonly Camera: 17;
readonly PhysicsEngine: 18;
readonly PhysicsBody: 19;
readonly Text: 20;

Text in the browser's own fonts, drawn from a canvas.

readonly CameraFollow: 21;

Moves its Camera to keep a target in view.

readonly Parallax: 22;

Moves its GameObject by a fraction of the camera's movement.

readonly UIRoot: 23;

Pins its GameObject (a HUD) to the camera's view.

readonly Button: 24;

Makes its SpriteRenderer clickable.

readonly Terrain: 25;

Ground drawn as one free-form shape. Edited in the editor; no script API yet.

readonly Light2D: 26;

A light for the camera's light map: a point, a spot or an image.

readonly CameraEffects: 27;

Lighting, bloom, colour grading and a vignette for its Camera.

readonly Joint2D: 28;

Ties the PhysicsBody to another one, or to the world: a pin, a rod, a spring, a rope, a weld or a slider.

readonly BoneFollower: 29;

Places a GameObject on a Spine bone.

Easeglobal 12 commands
const Ease

Easing curves for Tween.To.

readonly Linear: NEaseFunction;
readonly InQuad: NEaseFunction;
readonly OutQuad: NEaseFunction;
readonly InOutQuad: NEaseFunction;
readonly InCubic: NEaseFunction;
readonly OutCubic: NEaseFunction;
readonly InOutCubic: NEaseFunction;
readonly InSine: NEaseFunction;
readonly OutSine: NEaseFunction;
readonly InOutSine: NEaseFunction;
readonly OutBack: NEaseFunction;
readonly OutBounce: NEaseFunction;
GameObjectglobal 6 commands
const GameObject: NGameObjectStatics

The statics on the GameObject global. GameObject itself is an interface: the global is a plain object, so new GameObject() and instanceof GameObject do not work at runtime, and are no longer allowed to compile.

Find(name: string): GameObject | undefined;

Finds the first GameObject in the current scene with that name.

Create(args?: NGameObjectCreateArgs): GameObject;
Duplicate(trgGameObject: GameObject): GameObject;
Instantiate(prefabName: string, x?: number, y?: number): GameObject | undefined;

A new copy of the prefab called prefabName (with or without .prefab) and its children, the root at x, y when given. Its scripts start at once while the game is playing. Undefined when the project has no prefab of that name. Make a prefab with "Create Prefab" on a GameObject in the Hierarchy.

Destroy(gameObject: GameObject): void;
ExecuteFunctionOnScripts(gameObject: GameObject, functionName: string, args: unknown): void;

Calls functionName(args) on every Script component of gameObject.

GameStateglobal 10 commands
const GameState

Plain JSON values that survive SceneGraph.GotoScene: a score, lives, the level reached. Set and Get copy, so changing a value you read changes nothing until you Set it again. Cleared when Play starts and on Stop. Save / Load / HasSave / DeleteSave keep a copy in the browser, and Play and Stop do not remove it.

Get<T = any>(key: string, fallback?: T): T;

The value stored under key, or fallback (undefined if omitted) when there is none.

Set(key: string, value: unknown): void;

Stores a copy. Numbers, strings, booleans, arrays and plain objects; undefined removes the key. Throws on a function or a GameObject.

Has(key: string): boolean;
Remove(key: string): boolean;

Removes the key; returns whether it was there.

Clear(): void;
Keys(): string[];

Every stored key, in the order first set.

Save(slot: string): boolean;

Writes the current values to slot (a non-empty string of at most 64 characters; anything else throws). Returns false when no project is open or the browser refuses the write.

Load(slot: string): boolean;

Replaces the current values with the ones in slot. True when a save was found and loaded; false leaves the current values alone.

HasSave(slot: string): boolean;

Whether slot has a save for this project.

DeleteSave(slot: string): boolean;

Removes slot. True when a save was there and was removed.

Inputglobal 23 commands
const Input

Keyboard, mouse and standard-mapping gamepads. "This frame" means since the previous frame: every script in a frame sees the same presses and releases, exactly once. Pads are polled once at the start of the frame. Mouse presses count only on the game; keys typed into the inspector or the code editor never reach it; leaving the window releases keys, mouse buttons and pads (pads stay released until the window is focused again).

GetMousePosition(): NVector2;

Mouse position in canvas pixels, as 2018 scripts expect.

GetMouseWorldPosition(): NVector2;

Mouse position in world units, through the scene camera. Compare with GetLocalRect().

IsMouseDown(mouseButtonType: number): boolean;

The button is held, or was pressed this frame.

IsMouseUp(mouseButtonType: number): boolean;

The button is not held (the opposite of IsMouseDown).

IsMouseClick(mouseButtonType: number): boolean;

The button was clicked on the game this frame (pressed and released on it), as in 2018.

IsMousePressed(mouseButtonType: number): boolean;

The button went down this frame.

IsMouseReleased(mouseButtonType: number): boolean;

The button went up this frame.

IsKeyDown(keyCode: number): boolean;

The key is held, or was pressed this frame (a quick tap still counts for one frame).

IsKeyUp(keyCode: number): boolean;

The key is not down (the opposite of IsKeyDown).

IsKeyPressed(keyCode: number): boolean;

The key went down this frame. Holding it does not repeat.

IsKeyReleased(keyCode: number): boolean;

The key went up this frame.

DefineAction(name: string, keyCodes: number | number[], padButtons?: number | number[]): void;

Names a set of keys and, optionally, pad buttons, e.g. Input.DefineAction('Jump', [KeyCode.Space], [PadButton.A]). A pad button counts on any standard-mapping pad. Cleared when Play starts.

IsActionDown(name: string): boolean;

Any of the action's keys or pad buttons is down.

IsActionPressed(name: string): boolean;

One of the action's keys or pad buttons was pressed this frame.

IsActionReleased(name: string): boolean;

One of them was released this frame, and none of them is still down.

DefineAxis(name: string, axis?: NActionAxis): void;

Names an axis in −1…1, e.g. Input.DefineAxis('MoveX', { negativeKeys: [KeyCode.Left], positiveKeys: [KeyCode.Right], padAxis: 'LeftX' }). Cleared when Play starts, with the actions.

GetActionAxis(name: string): number;

The axis in −1…1. Keys contribute −1 or +1 (both directions cancel). The pad axis, after the dead zone, is used when its magnitude is strictly larger. An unknown name is 0.

IsPadDown(button: number, pad?: number): boolean;

The button is down this frame on pad (a getGamepads() index; 0 when omitted).

IsPadPressed(button: number, pad?: number): boolean;

The button went down on pad this frame. Holding it does not repeat.

IsPadReleased(button: number, pad?: number): boolean;

The button went up on pad this frame.

GetAxis(axis: NPadAxisName, pad?: number): number;

One stick axis after a 0.2 radial dead zone, rescaled so it is 0 just outside the zone and ±1 at full deflection. LeftY and RightY are negative when the stick is up. An unknown axis or a missing pad is 0.

Rumble(strong: number, weak: number, seconds: number, pad?: number): boolean;

Requests dual-motor rumble on a standard pad (index 0 by default). Magnitudes are clamped to 0..1; duration is in seconds. False when disabled, unsupported or arguments are invalid. Stop, blur and GotoScene stop every active effect.

rumbleEnabled: boolean;

Runtime option, true by default. Setting false also stops active rumble.

KeyCodeglobal 64 commands
const KeyCode: NKeyCodeMap

Keyboard codes, for Input.IsKeyDown, IsKeyPressed, IsKeyReleased and DefineAction.

readonly None: number;
readonly Backspace: number;
readonly JumpLine: number;
readonly Enter: number;
readonly Shift: number;
readonly Control: number;
readonly Escape: number;
readonly Space: number;
readonly QuotationMark: number;
readonly Left: number;
readonly Up: number;
readonly Right: number;
readonly Down: number;
readonly Num_0: number;
readonly Num_1: number;
readonly Num_2: number;
readonly Num_3: number;
readonly Num_4: number;
readonly Num_5: number;
readonly Num_6: number;
readonly Num_7: number;
readonly Num_8: number;
readonly Num_9: number;
readonly EqualsSign: number;
readonly A: number;
readonly B: number;
readonly C: number;
readonly D: number;
readonly E: number;
readonly F: number;
readonly G: number;
readonly H: number;
readonly I: number;
readonly J: number;
readonly K: number;
readonly L: number;
readonly M: number;
readonly N: number;
readonly O: number;
readonly P: number;
readonly Q: number;
readonly R: number;
readonly S: number;
readonly T: number;
readonly U: number;
readonly V: number;
readonly W: number;
readonly X: number;
readonly Y: number;
readonly Z: number;
readonly F1: number;
readonly F2: number;
readonly F3: number;
readonly F4: number;
readonly F5: number;
readonly F6: number;
readonly F7: number;
readonly F8: number;
readonly F9: number;
readonly F10: number;
readonly F11: number;
readonly F12: number;
readonly Backslash: number;
readonly Nothing: number;
Lightsglobal 2 commands
const Lights

CPU queries over enabled Light 2D components in the active scene.

At(x: number, y: number, layers?: number): number;

Summed light luminance at a world point, including ambient when the first scene camera has lighting on.

InRadius(x: number, y: number, radius: number): Light2D[];

Active Light 2D components whose world bounds touch a circle.

LightShapeglobal 3 commands
const LightShape

The shapes of a Light2D (light.shape).

readonly Point: 0;

A round pool of light around the centre.

readonly Spot: 1;

A cone along the GameObject's rotation.

readonly Sprite: 2;

An image as the light's shape: painted light shafts, window light.

MaskLayerFilterglobal 5 commands
const MaskLayerFilter

Render layers, combined as a bit mask, for a GameObject's own filter and the layers a Camera draws or a Light 2D lights. SystemOverlay is the engine's own debug pass. Collision categories are ColliderFilter, on colliders.

readonly Default: number;
readonly UI: number;
readonly Game: number;
readonly Background: number;
readonly SystemOverlay: number;
MeshFactoryglobal 3 commands
const MeshFactory

Builds the vertex and index arrays a MeshRenderer takes.

CreateQuad(width: number, height: number): NMeshData;

A quad centred on the origin.

CreateTextureQuad(width: number, height: number): NMeshData;

Same geometry as CreateQuad; the name is kept for saved scripts.

CreateCircle(radius: number, numEdges: number): NMeshData;

A fan of numEdges triangles, minimum 3.

MouseButtonglobal 3 commands
const MouseButton: NMouseButtonMap

Mouse buttons, for Input.IsMouseDown, IsMousePressed, IsMouseReleased and IsMouseClick.

readonly Left: number;
readonly Wheel: number;
readonly Right: number;
NColorglobal 7 commands
const NColor

Colours, as the material and renderer components take them.

Black(): NColorValue;
White(): NColorValue;
Red(): NColorValue;
Green(): NColorValue;
Blue(): NColorValue;
fromString(raw: string): NColorValue;

Parses 'r,g,b,a' as written by the inspector's colour swatch.

fromObject(obj: NColorValue): NColorValue;
NEnumComponentglobal 30 commands
const NEnumComponent: NComponentTypeMap

The spelling saved 2018-era projects use. Same object as ComponentType.

readonly Transform: 0;
readonly SpriteRenderer: 1;
readonly AnimationRenderer: 2;

Sprite Animation: frame clips on the SpriteRenderer.

readonly BoxCollider: 3;
readonly CircleCollider: 4;
readonly PolygonCollider: 5;

@deprecated Not implemented: AddComponent with it throws. The value is kept for saved scenes.

readonly ParticleSystemRenderer: 6;

Particle System: an emitter drawn in one batch.

readonly SpriteBatch: 7;

@deprecated Not implemented: AddComponent with it throws. The value is kept for saved scenes.

readonly AudioSource: 8;
readonly Material: 9;
readonly Shader: 10;

@deprecated Not implemented: AddComponent with it throws. The value is kept for saved scenes.

readonly Script: 11;
readonly SpineRenderer: 12;
readonly TileRenderer: 13;
readonly MeshRenderer: 14;
readonly BitmapText: 15;
readonly Animator: 16;
readonly Camera: 17;
readonly PhysicsEngine: 18;
readonly PhysicsBody: 19;
readonly Text: 20;

Text in the browser's own fonts, drawn from a canvas.

readonly CameraFollow: 21;

Moves its Camera to keep a target in view.

readonly Parallax: 22;

Moves its GameObject by a fraction of the camera's movement.

readonly UIRoot: 23;

Pins its GameObject (a HUD) to the camera's view.

readonly Button: 24;

Makes its SpriteRenderer clickable.

readonly Terrain: 25;

Ground drawn as one free-form shape. Edited in the editor; no script API yet.

readonly Light2D: 26;

A light for the camera's light map: a point, a spot or an image.

readonly CameraEffects: 27;

Lighting, bloom, colour grading and a vignette for its Camera.

readonly Joint2D: 28;

Ties the PhysicsBody to another one, or to the world: a pin, a rod, a spring, a rope, a weld or a slider.

readonly BoneFollower: 29;

Places a GameObject on a Spine bone.

NEnumInput_MouseButtonglobal 3 commands
const NEnumInput_MouseButton: NMouseButtonMap

The spelling saved 2018-era projects use. Same object as MouseButton.

readonly Left: number;
readonly Wheel: number;
readonly Right: number;
NEnumKeyCodeglobal 64 commands
const NEnumKeyCode: NKeyCodeMap

The spelling saved 2018-era projects use. Same object as KeyCode.

readonly None: number;
readonly Backspace: number;
readonly JumpLine: number;
readonly Enter: number;
readonly Shift: number;
readonly Control: number;
readonly Escape: number;
readonly Space: number;
readonly QuotationMark: number;
readonly Left: number;
readonly Up: number;
readonly Right: number;
readonly Down: number;
readonly Num_0: number;
readonly Num_1: number;
readonly Num_2: number;
readonly Num_3: number;
readonly Num_4: number;
readonly Num_5: number;
readonly Num_6: number;
readonly Num_7: number;
readonly Num_8: number;
readonly Num_9: number;
readonly EqualsSign: number;
readonly A: number;
readonly B: number;
readonly C: number;
readonly D: number;
readonly E: number;
readonly F: number;
readonly G: number;
readonly H: number;
readonly I: number;
readonly J: number;
readonly K: number;
readonly L: number;
readonly M: number;
readonly N: number;
readonly O: number;
readonly P: number;
readonly Q: number;
readonly R: number;
readonly S: number;
readonly T: number;
readonly U: number;
readonly V: number;
readonly W: number;
readonly X: number;
readonly Y: number;
readonly Z: number;
readonly F1: number;
readonly F2: number;
readonly F3: number;
readonly F4: number;
readonly F5: number;
readonly F6: number;
readonly F7: number;
readonly F8: number;
readonly F9: number;
readonly F10: number;
readonly F11: number;
readonly F12: number;
readonly Backslash: number;
readonly Nothing: number;
NHoming2Dclass 5 commands
class NHoming2D

Steers a point towards a target a little each frame.

SetTarget(targetX: number, targetY: number): void;
Update(args: NUpdateArgs): void;

Advances by args.dt.

GetX(): number;
GetY(): number;
GetRotation(): number;

Heading in radians, derived from the current velocity.

NIntervalclass 5 commands
class NInterval

A frame-driven timer. Construct it, Initialize it, then call Update(args) from the script's own update(args).

Initialize(intervalTimeInSeconds: number, loops: number): void;

Interval length in seconds, and how many times it fires.

AddListener_OnFinishedLoop(callback: () => void): void;

Fires after each loop except the last.

AddListener_OnFinishedInterval(callback: () => void): void;

Fires when the final loop completes.

Update(args: NUpdateArgs): void;

Advances the timer by args.dt.

Destroy(): void;
NMathglobal 13 commands
const NMath

Math helpers for game scripts.

Random(min: number, max: number): number;

A random number. Note this is the engine's historical formula, min + (max * random() - min), not the usual min + (max - min) * random().

Float2Int(value: number): number;

Truncates towards zero.

QuadraticBezier(vInitial: NVector2, vFinal: NVector2, vControl: NVector2, time: number): NVector2;
Lerp(value1: number, value2: number, time: number): number;

Linear interpolation; time is normally in [0, 1].

ToDegrees(radians: number): number;
ToRadians(degrees: number): number;
IsPowerOfTwo(value: number): boolean;
LowPrecisionCos(angle: number): number;

Fast approximation, accurate to about 0.001.

LowPrecisionSin(angle: number): number;

Fast approximation, accurate to about 0.001.

LowPrecision_Atan2(y: number, x: number): number;
IsPointInPolygon(point: NVector2, polygon: NVector2[]): boolean;

Ray-casting point-in-polygon test.

Min(val1: number, val2: number): number;
Max(val1: number, val2: number): number;
NVector2class 33 commands
class NVector2

A 2D vector. Both spellings are live: the PascalCase methods are aliases the engine installs for saved scripts, the camelCase ones are the framework's own.

x: number;
y: number;
Length(): number;

Magnitude of the vector.

Dot(other: NVector2): number;

Dot product with other.

Add(other: NVector2): void;

Adds other into this vector, in place.

Multiply(other: NVector2): void;

Multiplies component-wise by other, in place.

Scale(factor: number): void;

Multiplies both components by factor, in place.

Subtract(other: NVector2): void;
Divide(other: NVector2): void;
Normalize(): void;

Scales to unit length, in place.

Angle(): number;

Angle in radians.

ProjectionOn(other: NVector2): NVector2;
Clone(): NVector2;
length(): number;
dot(v: NVector2): number;
add(v: NVector2): void;
multiplyBy(factor: number): void;
multiply(v: NVector2): void;
scale(factor: number): void;
subtract(v: NVector2): void;
divide(v: NVector2): void;
angle(): number;
normalize(): void;
projectionOn(v: NVector2): NVector2;
clone(): NVector2;
static Zero(): NVector2;

(0, 0).

static One(): NVector2;

(1, 1).

static Left(): NVector2;

(-1, 0).

static Right(): NVector2;

(1, 0).

static zero(): NVector2;
static one(): NVector2;
static left(): NVector2;
static right(): NVector2;
PadButtonglobal 16 commands
const PadButton: NPadButtonMap

Pad buttons. See NPadButtonMap. Not GamepadButton: that name is the browser's constructor.

readonly A: 0;

Bottom face button (Cross).

readonly B: 1;

Right face button (Circle).

readonly X: 2;

Left face button (Square).

readonly Y: 3;

Top face button (Triangle).

readonly LB: 4;

Left bumper (L1).

readonly RB: 5;

Right bumper (R1).

readonly LT: 6;

Left trigger (L2).

readonly RT: 7;

Right trigger (R2).

readonly Back: 8;

Back / Select.

readonly Start: 9;

Start / Options.

readonly LS: 10;

Left stick click (L3).

readonly RS: 11;

Right stick click (R3).

readonly Up: 12;
readonly Down: 13;
readonly Left: 14;
readonly Right: 15;
ParticleEmissionglobal 1 command
const ParticleEmission

Emission settings for every Particle System at once, not for one component.

globalScale: number;

Multiplies the emission (rate and bursts) of every Particle System, on top of each one's own densityScale, including systems spawned later: ParticleEmission.globalScale = 0.6 for a low-quality setting. 0..2; 1 at Play and after Stop; kept across GotoScene.

Physicsglobal 5 commands
const Physics

Collision queries against the open scene, in world units, through the same shapes collisions use (scale, rotation, flip and parents included). They search the enabled colliders of enabled, active GameObjects, and work in edit and play mode.

filter is a ColliderFilter bitmask, e.g. ColliderFilter.Enemy | ColliderFilter.Object. A collider matches when its filter shares a bit with it; leave it out (or pass undefined) to match every collider. 0 matches none.

Shapes come from the world matrices composed at the start of the frame: an object a script moved earlier in the same update is found where it was, as with HitTest.

A TileRenderer's solid tiles and a Terrain's ground answer too: such a result's componentType is ComponentType.TileRenderer or ComponentType.Terrain and its gameObject is theirs. A Terrain is reported once per query, where a ray first meets its collider outline.

OverlapPoint(x: number, y: number, filter?: number, out?: Collider[]): Collider[];

Every Overlap and RaycastAll call takes an optional out array, emptied, filled and returned (no new array).

OverlapCircle(x: number, y: number, radius: number, filter?: number, out?: Collider[]): Collider[];

Every collider overlapping the circle centred on (x, y).

OverlapBox(x: number, y: number, width: number, height: number, rotationRadians?: number, filter?: number, out?: Collider[]): Collider[];

Every collider overlapping the width × height box centred on (x, y), rotated by rotationRadians (default 0).

Raycast(originX: number, originY: number, dirX: number, dirY: number, maxDistance?: number, filter?: number): NRaycastHit | null;

The nearest collider the ray from (originX, originY) along (dirX, dirY) meets, or null. The direction need not be normalized; a zero direction hits nothing. maxDistance is in world units; leave it out, or pass undefined or Infinity, for no limit.

RaycastAll(originX: number, originY: number, dirX: number, dirY: number, maxDistance?: number, filter?: number, out?: NRaycastHit[]): NRaycastHit[];

Every collider the ray meets within maxDistance, nearest first. Same arguments as Raycast.

Resourcesglobal 3 commands
const Resources

Looks assets up by name.

GetImage(name: string): NImageResource | null;
GetScript(name: string): NScriptResource | null;
GetSound(name: string): NSoundResource | null;
SceneGraphglobal 2 commands
const SceneGraph

Scene switching, and finding components across the open scene.

GotoScene(sceneName: string): void;

Switches to the scene with that name, with or without .scn, if the project has one.

FindComponents<K extends keyof NComponentByType>(componentType: K): Array<NonNullable<NComponentByType[K]>>;

Every component of one type on the open scene's active GameObjects (the engine's own objects left out), e.g. SceneGraph.FindComponents(ComponentType.ParticleSystemRenderer). A new array each call: cache it, don't call it every frame.

Soundglobal 10 commands
const Sound
PlayOneShot(sound: NSoundResource | string, options?: NOneShotOptions): boolean;PlayOneShot(sound: NSoundResource | string, volume?: number, options?: NOneShotOptions): boolean;PlayOneShot(sound: NSoundResource | string, volume?: number, pitch?: number, options?: NOneShotOptions): boolean;PlayOneShot(sound: NSoundResource | string, volume?: number, pitch?: number, pan?: number, options?: NOneShotOptions): boolean;

Plays sound (a sound resource, or its name as in Resources.GetSound) once. Volume (0..2), pitch (0.05..4) and pan (-1..1) default to the sound's own. The options object may follow any of them: PlayOneShot('Coin', { bus: 'UI' }). Returns false when the sound isn't loaded yet, or when its bus skipped it (the same sound within 40 ms, or a quieter sound than every voice of a full bus).

PlayOneShotAt(sound: NSoundResource | string, x: number, y: number, options?: NOneShotAtOptions): boolean;

A scene-owned one-shot at a world position. Attenuation and pan use the listener at the start only; later motion does not change them. Uses the same buses and voice limits as PlayOneShot. False when unloaded, beyond maxDistance, refused by audio or skipped by the bus.

StopAll(): void;

Stops every one-shot still playing. AudioSources are not affected.

SetBusVolume(name: NAudioBusName, volume: number): boolean;

Sets a bus's volume, 0 to 2 (Music, Effects, Ambience, UI). Returns false for an unknown bus. Reset to 1 by Play and Stop; not saved (keep options in GameState or your own storage).

GetBusVolume(name: NAudioBusName): number;

A bus's volume; 0 for an unknown bus.

SetBusLowpass(name: NAudioBusName, hz: number): boolean;

Puts a low-pass filter on a bus at hz (muffled, under water), or takes it off with 0.

Bus(name: NAudioBusName): NAudioBus | null;

A bus as an object, for Tween.To(Sound.Bus('Music'), { volume: 0.3 }, 1); null for an unknown name.

SetListener(gameObject: GameObject | null): void;

Uses a GameObject's world position as listener; null restores the first camera's view centre.

readonly Time: number;

The audio clock, in seconds. Use it with AudioSource.playAt and Sound.StartGroup.

StartGroup(sources: AudioSource[], at?: number): number | null;

Starts every AudioSource in sources at one audio-clock time, so music stems stay sample-locked: at, or 50 ms from now when absent. Returns the time used; null when there is no audio.

Swayglobal 1 command
const Sway

One world-space pusher shared by every built-in sway material.

SetPusher(x: number, y: number, radius: number, strength: number): void;

Radius in world units, strength in amplitude multiples; radius 0 disables the push.

Timeglobal 7 commands
const Time

The Play-session clock; rendering and audio keep their own unscaled time.

scale: number;

Game speed, clamped to 0..4; 1 at Play and after Stop. Changes apply on the next frame.

paused: boolean;

Stops scaled time and physics, retaining scale for resume. Input, UI and audio continue.

readonly dt: number;
readonly unscaledDt: number;
readonly realTime: number;

Unscaled seconds since Play; preserved by GotoScene and reset on Stop.

readonly hitStopRemaining: number;

Real seconds left of the current hit-stop; 0 when none.

HitStop(seconds: number): void;

Freezes scaled time for seconds of real time (a hit-stop, at most 1 s), then resumes by itself: Time.HitStop(0.04). The clock owns the restore, so a scene change cannot leave the game frozen (setting scale = 0 and restoring it from a Timer can: GotoScene cancels the timer). scale and paused are left as they are; calls overlap to the longest.

Timerglobal 3 commands
const Timer

Delays and repeats on the game's clock (seconds, the frame's dt), run right after every script's update, only while playing. Cancelled when the owner is destroyed, on Stop and on GotoScene.

After(seconds: number, callback: () => void, owner?: NSchedulerOwner, options?: NTimerOptions): NScheduledHandle;

Calls callback once, seconds from now.

Every(seconds: number, callback: () => void, owner?: NSchedulerOwner, times?: number, options?: NTimerOptions): NScheduledHandle;

Calls callback every seconds, times times (forever when omitted). A long frame fires once per interval it crossed.

CancelAll(owner?: NSchedulerOwner): void;

Cancels every timer and tween tied to owner, or all of them without one.

Tweenglobal 1 command
const Tween

Animates numbers over time. On a GameObject: x, y, scaleX, scaleY, rotation, and alpha (its SpriteRenderer's colour). On any other object: its own numeric properties.

Tween.To(this.gameObject, { y: 100, alpha: 0 }, 0.5, { ease: Ease.OutQuad, onComplete: () => GameObject.Destroy(this.gameObject) });
To(target: object, props: { [name: string]: number }, seconds: number, options?: NTweenOptions): NScheduledHandle;

Types

Descriptions of the things your code works with, like game objects and their settings.

AnimationRendererinterface 18 commands
interface AnimationRenderer extends Component

Sprite Animation (ComponentType.AnimationRenderer): frame clips played on the GameObject's SpriteRenderer while the game plays. It keeps animating off-screen unless updateWhenOffscreen says otherwise. A clip that does not loop stops on its last frame and calls onAnimationComplete(clipName) on the GameObject's scripts.

clips: NAnimationClip[];
defaultClip: string;

The clip playOnStart plays when the game starts (or when the object is spawned).

playOnStart: boolean;
speed: number;

Playback rate: 2 is twice as fast, 0 freezes.

updateWhenOffscreen: NOffscreenUpdate;

Whether it advances while its GameObject is off-screen (default 'always').

offscreenMargin: number;

For 'whenNear', in world units (default 256).

readonly isPlaying: boolean;
readonly currentClip: string;

The clip playing or last played; '' when none.

readonly frameIndex: number;

The frame shown, within the current clip.

play(name: string, restart?: boolean): boolean;

Plays the clip from its first frame. Already playing it: nothing happens, unless restart. Returns false when there is no clip by that name.

stop(): void;

Stops advancing; the current frame stays.

getClip(name: string): NAnimationClip | null;
addClip(name: string, images: ReadonlyArray<NImageResource>, fps?: number, loop?: boolean): NAnimationClip;

Adds a clip (or replaces the one with that name); the first clip becomes the default.

removeClip(name: string): boolean;
readonly IsPlaying: boolean;
readonly CurrentClip: string;
Play(name: string, restart?: boolean): boolean;
Stop(): void;
Animatorinterface 8 commands
interface Animator extends Component

Plays an animator graph.

updateWhenOffscreen: NOffscreenUpdate;

Whether it advances while its GameObject is off-screen (default 'always'). 'whenVisible': only while a camera drew it last frame; 'whenNear': while it was at most offscreenMargin world units outside the view. Objects with nothing to draw always count as on-screen.

offscreenMargin: number;

For 'whenNear', in world units (default 256).

animatorResouce: NAnimatorResource | null;

The runtime spelling, kept for saved projects.

readonly isPlaying: boolean;
readonly playingGraphs: ReadonlyArray<unknown>;

The graphs currently running.

play(animationName?: string): void;

Starts the graph's entry animation, or animationName if given.

stop(): void;
reset(): void;

Back to the first frame.

AudioSourceinterface 37 commands
interface AudioSource extends Component

Plays a sound resource. Every play() starts a new voice; stop() silences them all.

soundResource: NSoundResource | null;
volume: number;

0 to 2.

pan: number;

-1 fully left to 1 fully right; spatial sources use position while spatial is enabled.

pitch: number;

0 to 4; 1 is the recorded pitch.

isLoop: boolean;
playOnStart: boolean;

Plays once when Play is pressed and when the scene is entered with SceneGraph.GotoScene, after every script's initialize, if the component and its GameObject are enabled. Saved with the scene.

readonly isPlaying: boolean;
name: string;

Names this source on its GameObject, for GetAudioSource(name). Saved with the scene; '' when unnamed.

bus: NAudioBusName;

The mixer bus new plays go through: 'Effects' (the default), 'Music', 'Ambience' or 'UI'. Saved with the scene. Plays already sounding stay on their bus.

spatial: boolean;

Enables position-based gain and pan (off by default).

minDistance: number;

Full-volume radius, in world units.

maxDistance: number;

Silent radius, in world units.

rolloff: 'linear' | 'smooth' | 'inverse';

Distance curve.

panWidth: number;

Horizontal distance at which pan reaches its source pan limit.

autoPlayInRange: boolean;

Starts/stops an isLoop source as the listener enters/leaves its range.

readonly time: number;

Playback position of the latest play, in seconds of the sound: wrapped while looping, 0 before a scheduled play starts and when nothing of this source's is playing.

play(): void;

Starts a new play. The same sound started again on the same bus within 40 ms is skipped, and a bus at its voice cap (Effects: 24) drops its quietest voice.

playAt(time: number): void;

Like play(), starting at audio-clock time time (see Sound.Time). A time already past plays now.

stop(): void;
Volume: number;
Pan: number;
Pitch: number;
IsLoop: boolean;
PlayOnStart: boolean;

Same as playOnStart.

readonly IsPlaying: boolean;
Name: string;

Same as name.

Bus: NAudioBusName;

Same as bus.

Spatial: boolean;
MinDistance: number;
MaxDistance: number;
Rolloff: 'linear' | 'smooth' | 'inverse';
PanWidth: number;
AutoPlayInRange: boolean;
readonly Time: number;

Same as time.

Play(): void;
PlayAt(time: number): void;

Same as playAt.

Stop(): void;
BitmapTextinterface 5 commands
interface BitmapText extends Component

Text drawn from a bitmap font.

text: string;
color: NColorValue;
trackingQuantity: number;

Extra spacing between characters.

imageResource: NImageResource | null;
bitmapFontResource: NFontResource | null;
BoneFollowerinterface 4 commands
interface BoneFollower extends Component

Places this GameObject on a named Spine bone from itself or an ancestor.

boneName: string;
followRotation: boolean;
offsetX: number;
offsetY: number;
BoxColliderinterface 18 commands
interface BoxCollider extends Component

A box for collisions and hit tests. Sizes and offsets are in the GameObject's local units.

layer: string;

A project collision layer by name; empty: the filter bits decide. Two colliders with layers interact as the project's layer table says.

isTrigger: boolean;

Events only; as a PhysicsBody's shape, a sensor.

shadowCaster: boolean;

Its world rectangle blocks Light 2Ds that cast shadows (default false).

sizeX: number;
sizeY: number;
offsetX: number;
offsetY: number;
readonly localRect: NColliderRect;

The box in world units: scale, rotation and parents applied.

hitTest(other: BoxCollider | CircleCollider): boolean;
hitTestByPoint(x: number, y: number): boolean;
SetSizeX(value: number): void;
SetSizeY(value: number): void;
GetSizeX(): number;

2018 getters for sizeX / sizeY.

GetSizeY(): number;
SetOffsetX(value: number): void;
SetOffsetY(value: number): void;
GetLocalRect(): NColliderRect;

Same as localRect: world-space centre and size.

HitTest(other: BoxCollider | CircleCollider): boolean;
Buttoninterface 11 commands
interface Button extends Component

Button (ComponentType.Button): its SpriteRenderer, clickable while playing. A click (press and release on it, or hotkey) plays clickSound, calls onClick() on the GameObject's scripts and goes to targetScene.

normalColor: NColorValue;
hoverColor: NColorValue;
pressedColor: NColorValue;
clickSound: NSoundResource | null;
targetScene: string;

With or without .scn; empty for none.

hotkey: number;

A KeyCode; 0 for none.

interactable: boolean;
readonly isHovered: boolean;
readonly isPressed: boolean;
click(): void;

Does what a click does.

Click(): void;
Camerainterface 15 commands
interface Camera extends Component

A camera; GameObjects draw through the camera whose filter they match.

scaleMode: 'stretch' | 'fit' | 'expand' | 'free';

'stretch' fills the viewport (distorting), 'fit' letterboxes, 'expand' keeps the height and widens, 'free' is one unit per pixel (isFreeAspect).

shake(amplitude: number, seconds: number): void;

Shakes this camera by up to amplitude world units, fading over seconds.

Shake(amplitude: number, seconds: number): void;
readonly isShaking: boolean;
clearColor: NColorValue;
clearFlags: number;

WebGL clear bits: colour 16384, depth 256, both 16640.

width: number;
height: number;
zNear: number;
zFar: number;
depth: number;

Cameras draw in ascending depth.

isFreeAspect: boolean;
viewport: NViewport;

A copy: assign a whole viewport to change it.

readonly cameraMVP: NMatrix4;

View-projection matrix, updated every frame.

getViewportPixelRect(): { x: number; y: number; width: number; height: number };

The viewport in drawing-buffer pixels.

CameraEffectsinterface 24 commands
interface CameraEffects extends Component

Camera Effects (ComponentType.CameraEffects): what its Camera does to the picture. Every section is off by default. The numbers and the colours' channels can be tweened: Tween.To(effects.ambient, { r: 0, g: 0, b: 0.1 }, 1) darkens a cave, Tween.To(effects, { exposure: 1.4 }, 0.5) brightens the picture.

lighting: boolean;

Lights light the scene (Light 2D); off: everything draws unlit.

ambient: NColorValue;

The light where no light shines.

lightResolution: number;

The light map's size against the view: 0.25, 0.5 or 1 (anything else reads as 0.5).

bloom: boolean;

Bright parts glow.

bloomThreshold: number;

How bright a pixel must be to glow.

bloomKnee: number;

How gradually the glow starts above the threshold.

bloomIntensity: number;
bloomLevels: number;

How far the glow spreads: the number of blur levels, 1 to 4.

bloomQuality: 'low' | 'high';
exposure: number;

Brightness; 1 leaves the picture as it is.

contrast: number;

1 leaves the picture as it is.

saturation: number;

0 is grey, 1 leaves the picture as it is.

tint: NColorValue;

Multiplies the picture; white leaves it as it is.

vignette: boolean;

Darkens the edges of the view.

vignetteIntensity: number;
vignetteSmoothness: number;
vignetteColor: NColorValue;
fog: boolean;

Height fog over the world objects (never over the UI). World y grows downward: the air is clear above fogTop and the fog is at fogDensity at fogBottom and below. Tween.To(effects, { fogDensity: 0.8, fogTop: 300 }, 2) thickens it; Tween.To(effects.fogColor, { r: 0.4, g: 0.5, b: 0.6 }, 2) changes its colour.

fogColor: NColorValue;
fogDensity: number;

0 to 1 (default 0.6).

fogTop: number;

World y where the fog starts (default 0). A fogTop below fogBottom turns the band over: fog above.

fogBottom: number;

World y where the fog reaches full density (default 600).

fogNoise: number;

How much the drifting wisps thin the fog, 0 (even) to 1 (default 0).

fogSpeed: number;

How fast the wisps drift sideways, in world units a second (default 20).

CameraFollowinterface 13 commands
interface CameraFollow extends Component

Camera Follow (ComponentType.CameraFollow): keeps target in its Camera's view while the game plays, after scripts and physics moved it.

target: GameObject | null;

The GameObject followed: set it, or name it in targetName.

targetName: string;
deadZoneWidth: number;

The box around the view's centre inside which the target moves without the camera.

deadZoneHeight: number;
smoothTime: number;

Seconds to catch up; 0 snaps.

lookAhead: number;

Seconds of the target's velocity to look ahead by.

useBounds: boolean;

Keep the view inside the bounds rectangle.

boundsMinX: number;
boundsMinY: number;
boundsMaxX: number;
boundsMaxY: number;
snap(): void;

Jump straight to the target next frame.

Snap(): void;
CircleColliderinterface 11 commands
interface CircleCollider extends Component

A circle for collisions and hit tests.

layer: string;

A project collision layer by name; empty: the filter bits decide. Two colliders with layers interact as the project's layer table says.

isTrigger: boolean;

Events only; as a PhysicsBody's shape, a sensor.

radius: number;

A true radius, in the GameObject's local units.

offsetX: number;
offsetY: number;
hitTest(other: BoxCollider | CircleCollider): boolean;
hitTestByPoint(x: number, y: number): boolean;
SetRadius(value: number): void;
SetOffsetX(value: number): void;
SetOffsetY(value: number): void;
HitTest(other: BoxCollider | CircleCollider): boolean;
Collidertype
type Collider = BoxCollider | CircleCollider;

Either collider component: what collision hooks receive and Physics queries return.

Componentinterface 11 commands
interface Component extends NFiltered

What every component has in common.

readonly uid: string;
readonly GameObject: GameObject;
readonly Transform: NCTransform;
readonly ComponentType: number;

One of the ComponentType values.

IsEnabled: boolean;
readonly gameObject: GameObject;
readonly transform: NCTransform;
readonly componentType: number;
componentIndex: number;

Position among the GameObject's components.

readonly uniqueComponentIndex: number;

Identifies the component on its GameObject across saves.

isEnabled: boolean;
GameObjectinterface 35 commands
interface GameObject extends NFiltered

The basic object of a game: a transform plus a list of components.

readonly uid: string;
Name: string;
Tag: any;

Free-form; whatever a script puts here.

IsEnabled: boolean;
readonly Transform: NCTransform;
Z_Order: number;

Draw order.

GetZ_Order(): number;
SetZ_Order(value: number): void;
GetComponent<K extends keyof NComponentByType>(componentType: K, index?: number): NComponentByType[K] | null;GetComponent(componentType: number, index?: number): Component | null;

The component of that type, or the index-th one where there are several; null if none.

GetComponentsByType<K extends keyof NComponentByType>(componentType: K): NComponentByType[K][];GetComponentsByType(componentType: number): Component[];
GetComponentByType<K extends keyof NComponentByType>(componentType: K, scriptName?: string): NComponentByType[K] | null;GetComponentByType(componentType: number, scriptName?: string): Component | null;

The 2018 spelling of GetComponent: the first component of the type. For ComponentType.Script, scriptName picks the Script whose file has that name, with or without its extension.

readonly isVisible: boolean;

Drawn by a camera last frame: false off-screen (culled), disabled, or with nothing to draw. Scripts also get onBecameVisible / onBecameInvisible when it changes.

readonly IsVisible: boolean;

Same as isVisible.

GetAudioSource(name: string): AudioSource | null;

The AudioSource with this name (exact, then ignoring case), or null. Name them in the inspector.

getAudioSource(name: string): AudioSource | null;

Same as GetAudioSource.

HasColliderFilter(value: number): boolean;

Whether one of its enabled colliders has every bit of value (a ColliderFilter combination) in its own filter: other.HasColliderFilter(ColliderFilter.Enemy). Not ExistsFilter: a GameObject's own filter is its render layers (MaskLayerFilter), and ColliderFilter.Enemy is the same bit as MaskLayerFilter.UI.

hasColliderFilter(value: number): boolean;

Same as HasColliderFilter.

AddComponent<K extends keyof NComponentByType>(componentType: K): NComponentByType[K] | null;AddComponent(componentType: number): Component | null;

Adds a component of the given ComponentType and returns it; null if it may not be added.

name: string;
tag: any;
isEnabled: boolean;
readonly transform: NCTransform;
readonly components: Component[];
readonly scripts: Script[];
readonly colliders: Array<BoxCollider | CircleCollider>;
zOrder: number;
getComponent<K extends keyof NComponentByType>(componentType: K, index?: number): NComponentByType[K] | null;getComponent(componentType: number, index?: number): Component | null;
getComponentsByType<K extends keyof NComponentByType>(componentType: K): NComponentByType[K][];getComponentsByType(componentType: number): Component[];
getComponentByUniqueIndex(uniqueIndex: number): Component | undefined;
getComponentCount(componentType: number): number;
getComponentIndex(componentType: number): number;
getComponentByIndex(index: number): Component;
addComponent<K extends keyof NComponentByType>(componentType: K): NComponentByType[K] | null;addComponent(componentType: number): Component | null;
removeComponent(component: Component): void;
removeComponentByIndex(index: number): void;
Joint2Dinterface 31 commands
interface Joint2D extends Component

Joint 2D (ComponentType.Joint2D): ties this GameObject's PhysicsBody to another GameObject's (connectedName, or connected), or to the world when that is empty. A GameObject may have several. Built when Play starts, right after the bodies (or before the next step for one added while playing), reading the fields once; it goes with either body, and Stop ends it. Anchors and lengths are in world units (pixels), angles in degrees; maxMotorForce and breakForce are newtons, as PhysicsBody forces are (N·m for a revolute motor). The methods do nothing, and return 0, without a joint.

jointType: 'revolute' | 'distance' | 'rope' | 'weld' | 'prismatic';

'revolute' (default): a pin; 'distance': a rod or a spring; 'rope': a longest distance; 'weld'; 'prismatic': a slider.

connectedName: string;

The other GameObject, by name; empty (default): fixed to the world.

connected: GameObject | null;

The other GameObject itself (not saved): set it when names repeat, as in a rope built by a script. Setting it sets the name.

anchorX: number;

Where the joint is on this GameObject, in its local units (default 0, 0).

anchorY: number;
connectedAnchorX: number;

Where it is on the connected GameObject, in its local units; fixed to the world, an offset from the anchor in world units.

connectedAnchorY: number;
collideConnected: boolean;

Whether the two bodies still collide with each other (default false).

enableLimit: boolean;

Revolute: degrees from where it is at Play; prismatic: units along the axis.

lowerLimit: number;
upperLimit: number;
enableMotor: boolean;

Revolute: degrees per second; prismatic: units per second. Change it while playing with SetMotorSpeed.

motorSpeed: number;
maxMotorForce: number;
axisX: number;

Prismatic: the direction it slides along, in the world (default 0, 1).

axisY: number;
frequency: number;

Distance: 0 (default) a rigid rod, more a spring of that many hertz; dampingRatio 0 none, 1 critical.

dampingRatio: number;
maxLength: number;

Rope: the longest it gets; 0 (default) is the distance between the anchors at Play.

breakForce: number;

0 (default) never breaks; pulled harder, the joint breaks and the scripts get onJointBreak(joint).

readonly isBroken: boolean;

True once it broke in this Play session: it is not built again until the next Play.

GetReactionForce(): number;

The force the joint applied in the last step, in newtons.

getReactionForce(): number;
GetJointAngle(): number;

A revolute joint's angle in degrees, from where it was at Play.

getJointAngle(): number;
GetJointSpeed(): number;

Degrees per second (revolute) or units per second (prismatic).

getJointSpeed(): number;
SetMotorSpeed(speed: number): void;

Sets motorSpeed and the live motor's speed at once.

setMotorSpeed(speed: number): void;
Break(): void;

Breaks it now, as too much force would: the scripts get onJointBreak(joint).

break(): void;
Light2Dinterface 8 commands
interface Light2D extends Component

Light 2D (ComponentType.Light2D): a light for the light map of a camera whose Camera Effects has lighting on. The numbers and the colour's channels can be tweened, which is enough for a flicker or a pulse: Tween.To(light, { intensity: 2 }, 0.2). A value outside its range is kept to the nearest one in range.

shape: number;

A LightShape value (default LightShape.Point).

color: NColorValue;

The light's colour (default white).

intensity: number;

0 to 4 (default 1). Above 1 brightens past the sprite's own colour.

radius: number;

How far a Point or Spot light reaches, in world units (default 128).

softness: number;

0 is a hard edge, 1 a long smooth fade (default 0.5).

angle: number;

A Spot's full cone angle in degrees, 1 to 179 (default 60). It points along the GameObject's rotation.

castShadows: boolean;

Point and Spot: Terrains, and SpriteRenderers and BoxColliders with shadowCaster, block it (default false). Each light that casts shadows costs a few more draws, so keep it to the few that need it.

shadowSoftness: number;

The shadows' soft edge, 0 (hard) to 1 (default 0.5).

Materialinterface 6 commands
interface Material extends Component

Feeds a material's uniforms to the renderer on the same GameObject.

materialResouce: NMaterialResource | null;

The runtime spelling, kept for saved projects.

setMaterial_UniformData(uniformName: string, propName: string, value: unknown): void;
getUniform_UniformData(uniformName: string, propName: string, defaultValue?: unknown): unknown;
getUniformByName(uniformName: string): unknown;
SetMaterial_UniformData(uniformName: string, propName: string, value: unknown): void;
GetUniform_UniformData(uniformName: string, propName: string, defaultValue?: unknown): unknown;
MeshRendererinterface 12 commands
interface MeshRenderer extends Component

Draws polygons a script pushes each frame, between begin() and end().

readonly shaderResource: NShaderResource | null;
materialResource: NMaterialResource | null;
begin(): void;
pushPolygon(verticesOrData: number[] | NMeshData, triangles?: number[]): void;

Flat x, y vertices plus triangle indices, or the { vertices, indices } MeshFactory builds.

end(): void;
draw(args: NUpdateArgs, glRenderMode?: number): void;
overrideRenderingWithMaterial(): void;
Begin(): void;
PushPolygon(verticesOrData: number[] | NMeshData, triangles?: number[]): void;
End(): void;
Draw(args: NUpdateArgs, glRenderMode?: number): void;
OverrideRenderingWithMaterial(): void;
NActionAxisinterface 3 commands
interface NActionAxis

Digital keys plus one stick axis, for Input.DefineAxis.

negativeKeys?: number | number[];
positiveKeys?: number | number[];
padAxis?: NPadAxisName;

Read from every standard-mapping pad; the greatest magnitude is the one that counts.

NAnimationClipinterface 4 commands
interface NAnimationClip

A Sprite Animation clip.

name: string;
frames: NAnimationFrame[];
fps: number;
loop: boolean;
NAnimationFrameinterface 2 commands
interface NAnimationFrame

One frame of a Sprite Animation clip: the image, or null when it was removed from the project.

uid: string;
image: NImageResource | null;
NAnimatorResourceinterface
interface NAnimatorResource extends NResource
NAudioBusinterface 3 commands
interface NAudioBus

A mixer bus, from Sound.Bus(name). Its numeric properties can be animated with Tween.To.

readonly name: NAudioBusName;
volume: number;

0 to 2; 1 is unchanged. Reset to 1 by Play and Stop; not saved.

lowpass: number;

Low-pass cut-off in Hz (10 to 22050); 0 is off. Reset to 0 by Play and Stop; not saved.

NAudioBusNametype
type NAudioBusName = 'Music' | 'Effects' | 'Ambience' | 'UI';

A mixer bus name. Names are matched ignoring case.

NColliderRectinterface 8 commands
interface NColliderRect

A collider's bounds, in world units; centre plus size. Both spellings are filled in.

x: number;
y: number;
width: number;
height: number;
X: number;
Y: number;
Width: number;
Height: number;
NColorValueinterface 4 commands
interface NColorValue

A colour, channels in 0..1. What renderers hold and NColor returns.

r: number;
g: number;
b: number;
a: number;
NComponentByTypeinterface 26 commands
interface NComponentByType

The component interface for each ComponentType a GameObject can actually hold. Transform is absent on purpose: it is not one of components, so GetComponent(ComponentType.Transform) returns null — use transform instead. The unimplemented types are absent too.

1: SpriteRenderer;
2: AnimationRenderer;
3: BoxCollider;
4: CircleCollider;
6: ParticleSystemRenderer;
8: AudioSource;
9: Material;
11: Script;
12: SpineRenderer;
13: TileRenderer;
14: MeshRenderer;
15: BitmapText;
16: Animator;
17: Camera;
18: PhysicsEngine;
19: PhysicsBody;
20: Text;
21: CameraFollow;
22: Parallax;
23: UIRoot;
24: Button;
25: Terrain;
26: Light2D;
27: CameraEffects;
28: Joint2D;
29: BoneFollower;
NCTransforminterface 23 commands
interface NCTransform extends Component

Position, scale, rotation and parenting for a GameObject. It is a component, but not one of components: reach it through transform.

Parent: NCTransform;

The transform this one is parented to, or null.

readonly Childs: NCTransform[];
SetParent(transform: NCTransform): void;

Re-parents, keeping the world position.

Position: NVector2;
Scale: NVector2;
Rotation: number;

Radians.

Depth: number;

Draw order; the GameObject's Z_Order writes through to this.

FlippedX: boolean;
FlippedY: boolean;
parent: NCTransform;
readonly childs: NCTransform[];
setParent(transform: NCTransform, worldPositionStays?: boolean): void;

Re-parents; worldPositionStays (default true) keeps the world position.

existsChild(transform: NCTransform): { exists: boolean; index: number };
position: NVector2;
scale: NVector2;
rotation: number;
depth: number;
flippedX: boolean;
flippedY: boolean;
readonly translatedMatrix: NMatrix4;

Rebuilt every frame, before scripts' update. Read-only in practice.

readonly rotationMatrix: NMatrix4;
readonly scaleMatrix: NMatrix4;
readonly transformedMatrix: NMatrix4;

The world matrix: translation · scale · rotation, composed with every parent's.

NEaseFunctiontype
type NEaseFunction = (t: number) => number;

An easing curve: progress 0..1 in, eased progress out (starts at 0, ends at 1).

NFilteredinterface 9 commands
interface NFiltered

A bit mask whose meaning depends on its owner. On a GameObject: its render layers (MaskLayerFilter). On a BoxCollider or CircleCollider: its collision categories (ColliderFilter). On a Camera or Light 2D: the render layers it draws or lights. The two vocabularies share bits, so use each only on its own owner. filter is a binary string; combine values with |.

readonly filter: string;

The filter as a binary string, e.g. '101'.

setFilter(value: number): void;

Replaces the filter with value.

addFilter(value: number): void;
removeFilter(value: number): void;
existsFilter(value: number): boolean;

Whether every bit of value is set.

SetFilter(value: number): void;
AddFilter(value: number): void;
RemoveFilter(value: number): void;
ExistsFilter(value: number): boolean;
NFontResourceinterface
interface NFontResource extends NResource
NGameObjectCreateArgsinterface 8 commands
interface NGameObjectCreateArgs

The arguments GameObject.Create accepts.

Name?: string;
name?: string;
ParentGameObject?: GameObject;
position?: NVector2;
scale?: NVector2;
rotation?: number;
flippedX?: boolean;
flippedY?: boolean;
NGenericResourceinterface
interface NGenericResource extends NResource

A text or binary asset, such as a Spine atlas or skeleton file.

NImageResourceinterface 12 commands
interface NImageResource extends NResource

An image asset, or one slice of a sprite sheet.

readonly imageRectX: number;
readonly imageRectY: number;
readonly imageRectWidth: number;
readonly imageRectHeight: number;
readonly subImagesCount: number;

How many slices this sheet was cut into.

readonly imageResourceParent: NImageResource | null;

For a slice, the sheet it came from.

GetImageRectX(): number;
GetImageRectY(): number;
GetImageRectWidth(): number;
GetImageRectHeight(): number;
GetSubImagesCount(): number;
GetImageResourceParent(): NImageResource | null;
NInspectorHintinterface 9 commands
interface NInspectorHint

How the inspector draws one exposed field. Declared on the script class:

static inspector: NInspectorHints = {
  speed: { header: 'Movement', min: 0, max: 600, step: 10, tooltip: 'Units per second' },
  mode: { options: ['loop', { value: 'ping-pong', label: 'Ping-pong' }] },
  tint: { kind: 'color' },
  target: { kind: 'gameObject' },
};

Hints change how a row looks, never what is saved. A 'gameObject' field holds null while editing and the chosen GameObject (or null when it is gone) at Play.

label?: string;

Row label; by default the field name in words (jumpHeight → "Jump height").

tooltip?: string;

Shown on hover.

header?: string;

A heading above this row and the rows after it.

min?: number;

Numbers are kept within min and max; with both, a slider is drawn too.

max?: number;
step?: number;
options?: Array<string | number | { value: string | number; label?: string }>;

A dropdown of these values (strings or numbers), optionally with labels.

kind?: 'color' | 'multiline' | 'gameObject';

'color': a colour picker over a #rrggbb string. 'multiline': a text area. 'gameObject': a scene object.

hidden?: boolean;

Not shown in the inspector and not saved.

NInspectorHintstype
type NInspectorHints = { [field: string]: NInspectorHint };

A script class's static inspector: hints by field name.

NLightingtype
type NLighting = 'lit' | 'unlit';

Whether a renderer takes its camera's lighting (lighting).

NMaterialResourceinterface
interface NMaterialResource extends NResource
NMatrix4type
type NMatrix4 = Float32Array | number[];

A 4×4 matrix, column-major, as gl-matrix lays it out.

NMeshDatainterface 2 commands
interface NMeshData

The vertex/index pair MeshFactory produces, as MeshRenderer consumes it.

vertices: number[];

Flat x, y pairs.

indices: number[];
NOffscreenUpdatetype
type NOffscreenUpdate = 'always' | 'whenVisible' | 'whenNear';

Off-screen update policy of Script, Animator, SpineRenderer, SpriteAnimation and ParticleSystem.

NOneShotAtOptionsinterface 6 commands
interface NOneShotAtOptions extends NOneShotOptions

Settings for Sound.PlayOneShotAt; spatial defaults match AudioSource.

volume?: number;

0..2; defaults to the sound resource's volume, before attenuation.

pitch?: number;

0.05..4; defaults to the sound resource's pitch.

minDistance?: number;

Full volume within this distance; default 100.

maxDistance?: number;

Silent at this distance; beyond it no voice starts. Default 1000.

rolloff?: 'linear' | 'smooth' | 'inverse';

Default 'smooth'.

panWidth?: number;

Horizontal distance for full left/right pan; default 600. Zero centres the sound.

NOneShotOptionsinterface 1 command
interface NOneShotOptions

The last argument of Sound.PlayOneShot.

bus?: NAudioBusName;

The bus it plays on; 'Effects' when absent.

NPadAxisNametype
type NPadAxisName = 'LeftX' | 'LeftY' | 'RightX' | 'RightY';

A stick axis Input.GetAxis and Input.DefineAxis understand. Y is negative when the stick is up.

NRaycastHitinterface 4 commands
interface NRaycastHit

One hit of Physics.Raycast / Physics.RaycastAll.

readonly collider: Collider;

The collider the ray hit.

readonly point: NVector2;

Where the ray enters the collider, in world units; the origin itself when it starts inside.

readonly distance: number;

From the origin to point, in world units. 0 when the ray starts inside the collider.

readonly normal: NVector2;

The surface's outward normal at point, unit length: normal.y < 0 is a floor seen from above. (0, 0) when the ray starts inside the collider.

NResourceinterface 3 commands
interface NResource

What every asset has in common.

readonly uid: string;
readonly path: string;

The project path, e.g. sprites/player.png.

readonly isLoaded: boolean;
NScheduledHandleinterface 2 commands
interface NScheduledHandle

Returned by Timer.After, Timer.Every and Tween.To.

Cancel(): void;

Stops it; does nothing when it already finished.

readonly IsActive: boolean;

Still waiting or running.

NSchedulerOwnertype
type NSchedulerOwner = GameObject | Component;

A GameObject or a component: what a timer or tween can be tied to. Destroying it cancels them.

NScriptHooksinterface 36 commands
interface NScriptHooks

Hooks the engine calls on a script, besides the constructor, if the script defines them. Each is looked up camelCase first, then PascalCase, so update and Update both work. Declared for reference — a script does not need to implement it.

preInitialize?(): void;
initialize?(): void;

Exposed property values from the Inspector are in place by now; read them here.

postInitialize?(): void;
update?(args: NUpdateArgs): void;
onCollision?(other: Collider): void;

Every frame one of this GameObject's colliders overlaps other, the other object's collider. The 2018 contract; called after onCollisionEnter / onCollisionStay on the same frame.

onCollisionEnter?(other: Collider): void;

The first frame this GameObject's collider overlaps other.

onCollisionStay?(other: Collider): void;

Every frame of an overlap with other, the first one included (right after onCollisionEnter).

onCollisionExit?(other: Collider): void;

The first frame after an overlap with other ends: they separated, or other (or its GameObject, or a parent) was disabled or destroyed. Not called on Stop or on a scene switch.

onBecameVisible?(): void;

A camera drew this GameObject this frame and not the frame before (it came into view, or was drawn for the first time since Play). Called after every camera has drawn; see GameObject.isVisible.

onBecameInvisible?(): void;

No camera drew this GameObject this frame, though one did the frame before (it left every view).

onAnimationComplete?(clipName: string): void;

A Sprite Animation clip that does not loop reached its last frame.

onSpineEvent?(name: string, event: { int: number; float: number; string: string; time: number }): void;

A Spine event delivered after this GameObject's component tick.

onSpineComplete?(animationName: string, track: number): void;

A Spine track crossed an animation completion boundary.

onContactEnter?(other: GameObject, normal: NVector2): void;

This GameObject's physics body started touching other's (needs a PhysicsEngine). normal points from other towards this object: normal.y < 0 means other is below. Sensors report too, with a zero normal. Called after the physics step, not from inside it.

onContactExit?(other: GameObject): void;

The bodies stopped touching. Not called on Stop.

onJointBreak?(joint: Joint2D): void;

One of this GameObject's Joint 2Ds broke: pulled harder than its breakForce, or Break() was called. Called once, after the physics step; the joint is gone and is not built again until the next Play.

onClick?(): void;

This GameObject's Button was clicked.

destroy?(): void;
PreInitialize?(): void;
Initialize?(): void;
PostInitialize?(): void;
Update?(args: NUpdateArgs): void;
OnCollision?(other: Collider): void;
OnCollisionEnter?(other: Collider): void;
OnCollisionStay?(other: Collider): void;
OnCollisionExit?(other: Collider): void;
OnBecameVisible?(): void;
OnBecameInvisible?(): void;
OnAnimationComplete?(clipName: string): void;
OnSpineEvent?(name: string, event: { int: number; float: number; string: string; time: number }): void;
OnSpineComplete?(animationName: string, track: number): void;
OnContactEnter?(other: GameObject, normal: NVector2): void;
OnContactExit?(other: GameObject): void;
OnJointBreak?(joint: Joint2D): void;
OnClick?(): void;
Destroy?(): void;
NScriptResourceinterface
interface NScriptResource extends NResource

A script asset. Scripts are attached through the Script component, not called directly.

NShaderResourceinterface
interface NShaderResource extends NResource
NSoundResourceinterface 8 commands
interface NSoundResource extends NResource

A sound asset. The properties are the defaults an AudioSource starts from.

volume: number;
isLoop: boolean;
pan: number;

-1 fully left to 1 fully right.

pitch: number;
Volume: number;
IsLoop: boolean;
Pan: number;
Pitch: number;
NTimerOptionsinterface 1 command
interface NTimerOptions
unscaled?: boolean;

Advance in real seconds, including while Time.paused.

NTweenOptionsinterface 4 commands
interface NTweenOptions extends NTimerOptions
ease?: NEaseFunction;

One of Ease, or any (t) => number. Ease.Linear when omitted.

delay?: number;

Seconds to wait first; the start values are read when it begins.

owner?: NSchedulerOwner | null;

Cancelled when this is destroyed. A GameObject target is its own owner unless you say otherwise.

onComplete?: () => void;
NUpdateArgsinterface 3 commands
interface NUpdateArgs

What the engine passes to update(args) and to NInterval / NHoming2D.

dt: number;

Scaled seconds this frame; unscaled for a Script with useUnscaledTime.

unscaledDt?: number;

Real seconds this frame and since Play, also available while paused.

realTime?: number;
NViewportinterface 4 commands
interface NViewport

A camera viewport, in 0..1 of the canvas.

x: number;
y: number;
width: number;
height: number;
Parallaxinterface 7 commands
interface Parallax extends Component

Parallax (ComponentType.Parallax): 0 scenery, 1 moves with the camera (far), negative foreground.

factorX: number;
factorY: number;
hazeColor: NColorValue;

Depth haze: the colour this object and its children mix towards (white by default).

hazeAmount: number;

How much of it, 0..1 (0 by default: no haze). A Tween target.

useCameraOrigin: boolean;

Count the camera's movement from cameraOriginX/Y instead of from where Play started (read on the first frame).

cameraOriginX: number;
cameraOriginY: number;
ParticleSystemRendererinterface 60 commands
interface ParticleSystemRenderer extends Component

Particle System (ComponentType.ParticleSystemRenderer): emits particles while the game plays (it keeps simulating off-screen unless updateWhenOffscreen says otherwise). Sizes and speeds in world units, angles in degrees (0 = +x, 90 = down), times in seconds.

rate: number;
bursts: Array<{ time: number; count: number }>;
duration: number;
loop: boolean;
lifetimeMin: number;
lifetimeMax: number;
speedMin: number;
speedMax: number;
angleMin: number;
angleMax: number;
gravityX: number;
gravityY: number;
maxParticles: number;
startColor: NColorValue;
endColor: NColorValue;
startSize: number;
endSize: number;
worldSpace: boolean;

Particles stay where they were emitted when the emitter moves (false: they move with it).

playOnStart: boolean;
blendMode: number;

A BlendMode value (default BlendMode.Alpha).

lighting: NLighting;

Whether a camera with Camera Effects lighting lights it: 'lit' (the default) or 'unlit', for glows and UI.

sheetColumns: number;

Flipbook columns and rows in imageResource (defaults 1 × 1).

sheetRows: number;
frameMode: 'overLife' | 'fps';

Selects frames across life, or advances them at frameFps.

frameFps: number;
randomStartFrame: boolean;
shape: 'point' | 'circle' | 'box' | 'line';
shapeRadius: number;
fromEdge: boolean;
shapeWidth: number;
shapeHeight: number;
shapeLength: number;
shapeAngle: number;

Internal emitter orientation in degrees; normally follows the GameObject transform.

rotationMin: number;
rotationMax: number;
spinMin: number;
spinMax: number;
alignToVelocity: boolean;
stretch: number;
noiseStrength: number;
noiseFrequency: number;
drag: number;
fadeIn: number;
midColor: NColorValue | null;
midTime: number;
prewarm: boolean;
densityScale: number;

Runtime-only multiplier for rate and bursts; defaults to 1 and is not saved.

imageResource: NImageResource | null;
updateWhenOffscreen: NOffscreenUpdate;
offscreenMargin: number;
readonly particleCount: number;
readonly isPlaying: boolean;
play(): void;
stop(): void;
burst(count: number): void;
clear(): void;
Play(): void;
Stop(): void;
Burst(count: number): void;
Clear(): void;
PhysicsBodyinterface 56 commands
interface PhysicsBody extends Component

A Box2D body while the game plays. Its shape is the GameObject's BoxCollider (size only: offset, scale and rotation are not applied), friction 1, fixed rotation; the transform's position follows it. Built when Play starts, after every script's Initialize. Live settings store their values even without a body; forces and velocity methods need a body. Units are Box2D's: newtons, N·s, m/s (100 px = 1 m).

DropThrough(seconds?: number): void;

Pass through every one-way Terrain for 0.25 seconds by default; repeating extends the window. The next physics step releases a standing contact with one onContactExit and clears its grounding. Two-sided terrain and other bodies are unaffected; a pass raises no further contact hooks.

dropThrough(seconds?: number): void;
bodyType: 'static' | 'dynamic' | 'kinematic';

Live. 'kinematic' moves only by its velocity; static to dynamic starts at rest and wakes.

friction: number;

Live surface friction on every fixture, including existing contacts (default 1).

restitution: number;

Live bounciness on every fixture, 0 – 1 (default 0).

linearDamping: number;

Live damping: slows the body over time, 1/s (default 0).

gravityScale: number;

Live gravity scale: 0 floats, 1 normal, -1 falls up (default 1).

fitShape: boolean;

Fit the body to its collider: its offset and the transform's scale (default false: 2018's box).

fixedRotation: boolean;

Live. False lets the body rotate; the transform's rotation follows it (default true).

SetBodyType(value: 'static' | 'dynamic' | 'kinematic'): void;
SetGravityScale(value: number): void;
SetLinearDamping(value: number): void;
SetFriction(value: number): void;
SetRestitution(value: number): void;
SetSensor(value: boolean): void;
SetFixedRotation(value: boolean): void;
SetAwake(value: boolean): void;

Wake or put the body to sleep; does nothing without a body. Sleeping clears its velocity.

IsAwake(): boolean;

False without a body.

readonly isGrounded: boolean;

Standing on something: touching a solid body whose contact normal points up within 45° of vertical. False before Play has built the body.

readonly IsGrounded: boolean;
GetContacts(): GameObject[];

The GameObjects whose bodies touch this one now (sensors included).

getContacts(): GameObject[];
SetVelocityPx(x: number, y: number): void;

Velocity in pixels per second.

GetVelocityPxX(): number;
GetVelocityPxY(): number;
density: number;

Shapes the body.

isStatic: boolean;

Live alias for bodyType: true sets static, false changes static to dynamic.

isSensor: boolean;

Live on every fixture: overlaps instead of colliding, while keeping contact reports.

mass: number;

Stored and returned by their getters, as in 2018; the body does not read them.

inertia: number;
angularVelocity: number;
velocityX: number;
velocityY: number;
IsStatic: boolean;
IsSensor: boolean;
ApplyForce(x: number, y: number): void;

A force in newtons at the centre of mass, for the next step.

ApplyLinearImpulse(x: number, y: number): void;

An impulse in N·s: an immediate change of velocity.

SetLinearVelocity(x: number, y: number): void;

In m/s.

SetLinearVelocityX(x: number): void;
SetLinearVelocityY(y: number): void;
GetLinearVelocityX(): number;

The body's velocity in m/s; 0 before Play.

GetLinearVelocityY(): number;
SetPosition(x: number, y: number): void;

Teleports: moves the GameObject to (x, y) in pixels, and its body with it, keeping the body's velocity and waking it. Writing Transform.Position alone is undone by the next physics step.

setPosition(x: number, y: number): void;

Same as SetPosition.

GetVelocityX(): number;

The stored values (2018 names).

GetVelocityY(): number;
GetAngularVelocity(): number;
GetInertia(): number;
GetDensity(): number;
GetMass(): number;
SetVelocityX(value: number): void;
SetVelocityY(value: number): void;
SetAngularVelocity(value: number): void;
SetInertia(value: number): void;
SetDensity(value: number): void;
SetMass(value: number): void;
PhysicsEngineinterface 10 commands
interface PhysicsEngine extends Component

Turns physics on: with one enabled on any GameObject, Play builds a Box2D world for every PhysicsBody. Gravity is (0, 10) m/s², +y down; 100 px = 1 m. The world advances 1/30 s per 1/60 s of real time, as 2018 did at 60 fps.

gravityX: number;

Gravity in m/s², +y down (default 0, 10). Read when Play starts.

gravityY: number;
timeScale: number;

Simulated seconds per real second (default 2, the 2018 speed).

pixelsPerMeter: number;

Scene pixels per metre (default 100).

offsetX: number;

Stored, and unused, as in 2018.

offsetY: number;
GetOffsetX(): number;
GetOffsetY(): number;
SetOffsetX(value: number): void;
SetOffsetY(value: number): void;
Scriptinterface 22 commands
interface Script extends Component

Runs a script resource on its GameObject.

useUnscaledTime: boolean;

Use real seconds in update, including while paused (default false; inspector checkbox).

updateWhenOffscreen: NOffscreenUpdate;

Whether update runs (hooks always do) while its GameObject is off-screen (default 'always'). 'whenVisible': only while a camera drew it last frame; 'whenNear': while it was at most offscreenMargin world units outside the view. Objects with nothing to draw always count as on-screen.

offscreenMargin: number;

For 'whenNear', in world units (default 256).

resource: NScriptResource | null;
readonly scriptInstance: any;

The running instance of the script while the game plays, null otherwise. Typed any because it is whatever class or constructor function the user wrote.

readonly isExecutingScript: boolean;
readonly scriptFileName: string;

The script resource's file name, e.g. Player.ts.

readonly hasCompileErrors: boolean;
setScriptProperty(name: string, value: unknown): void;

Sets one of the script's exposed properties.

invokeHook(camelName: string, pascalName: string, ...args: unknown[]): boolean;

Calls camelName on the running instance, or pascalName if it has no function by that name. Returns whether either was found.

executeScript_Ctor(): void;
executeScript_Initialize(): void;
executeScript_PostInitialize(): void;
executeScript_Stop(): void;
SetResource(resource: NScriptResource): void;
GetResource(): NScriptResource | null;
GetScriptInstance(): any;

2018 name of scriptInstance: the running instance while playing, null otherwise.

SetScriptProperty(name: string, value: unknown): void;
ExecuteScript_Ctor(): void;

Constructs the script; call ExecuteScript_Initialize after it when spawning at runtime.

ExecuteScript_Initialize(): void;
ExecuteScript_PostInitialize(): void;
ExecuteScript_Stop(): void;
SpineRendererinterface 33 commands
interface SpineRenderer extends Component

A Spine skeleton animation.

lighting: NLighting;

Whether a camera with Camera Effects lighting lights it: 'lit' (the default) or 'unlit', for glows and UI.

updateWhenOffscreen: NOffscreenUpdate;

Whether the animation advances while its GameObject is off-screen (default 'always'). 'whenVisible': only while a camera drew it last frame; 'whenNear': while it was at most offscreenMargin world units outside the view. Objects with nothing to draw always count as on-screen.

offscreenMargin: number;

For 'whenNear', in world units (default 256).

flipX: boolean;
flipY: boolean;
isLoop: boolean;
imageResource: NImageResource | null;
genericResourceAtlas: NGenericResource | null;
genericResourceJson: NGenericResource | null;
readonly isSpineReady: boolean;
readonly skeleton: any;

The spine-ts runtime objects. Typed any: the spine typings are not shipped to scripts.

readonly animationState: any;
readonly animationStateData: any;
readonly availableAnimations: ReadonlyArray<{ readonly name: string; readonly duration: number }>;
readonly availableSkins: ReadonlyArray<{ readonly name: string }>;
readonly currentAnimationName: string;
readonly currentAnimationSkinName: string;
hitTestByPoint(x: number, y: number): boolean;
setSkin(skinName: string): void;
setAnimation(animationName: string, loop?: boolean, skipSame?: boolean, track?: number): void;

loop defaults to the component's isLoop; skipSame ignores a request for the current one.

addAnimation(animationName: string, loop: boolean, delay: number, track?: number): void;
setMix(from: string, to: string, seconds: number): void;
defaultMix: number;
timeScale: number;
clearTrack(track: number): void;
setEmptyAnimation(track: number, mix: number): void;
getCurrent(track?: number): { name: string; time: number; duration: number; complete: boolean } | null;
getBoneWorldPosition(boneName: string): { x: number; y: number } | null;
getBoneWorldRotation(boneName: string): number | null;
SetFlipX(value: boolean): void;
SetFlipY(value: boolean): void;
GetFlipX(): boolean;
GetFlipY(): boolean;
SpriteRendererinterface 22 commands
interface SpriteRenderer extends Component

Draws an image, optionally through a material.

cullPadding: number | undefined;

Extra bounds in world units; undefined (default) never culls a sprite with a material. Zero opts in.

drawMode: 'simple' | 'tiled' | 'sliced';

'simple' draws the image once at its size; 'tiled' repeats it over sizeX × sizeY; 'sliced' stretches it in nine parts, keeping the image's slice borders (set in the Image inspector).

sizeX: number;

The size covered when Tiled or Sliced, in world units; 0 uses the image's.

sizeY: number;
readonly imageWidth: number;

The image's own size in pixels.

readonly imageHeight: number;
readonly drawnWidth: number;

The size it draws at.

readonly drawnHeight: number;
fitBoxCollider(): boolean;

Sets the first BoxCollider to the drawn size; false without one.

blendMode: number | null;

A BlendMode value, or null (the default) to use its material's mode, which is Alpha without a material. Its own value wins over the material's.

lighting: NLighting;

Whether a camera with Camera Effects lighting lights it: 'lit' (the default) or 'unlit', for glows and UI.

shadowCaster: boolean;

Its drawn quad blocks Light 2Ds that cast shadows (default false).

color: NColorValue;
imageResource: NImageResource | null;
readonly shaderResource: NShaderResource | null;
materialResource: NMaterialResource | null;
hitTestByPoint(x: number, y: number): boolean;

Whether (x, y) falls on the drawn sprite.

SetImageResource(resource: NImageResource): void;
GetImageResource(): NImageResource | null;
SetColor(color: NColorValue): void;
GetColor(): NColorValue;
SetMaterialResource(resource: NMaterialResource): void;
Terraininterface 6 commands
interface Terrain extends Component

Read-only surface information from GetComponentByType(ComponentType.Terrain).

readonly profileName: string;

The Terrain Profile resource's name, or '' without one.

readonly isOneWay: boolean;
readonly isClosed: boolean;
readonly hasCollider: boolean;

Whether the Terrain's Collider setting is on.

readonly layer: string;
edgeAt(x: number, y: number): string;

The nearest outline segment's edge name at a world point, measured in Terrain local space. Includes holes; uses the per-point edge first, then the profile's slope range. 'none', an unmatched side, a missing profile or an unusable transform returns ''.

Textinterface 20 commands
interface Text extends Component

Text (ComponentType.Text). Drawn as one quad centred on the transform; redrawn when a property changes, and once more when a Font resource named in fontFamily finishes loading. Sizes are in world units.

lighting: NLighting;

Whether a camera with Camera Effects lighting lights it: 'lit' (the default) or 'unlit', for glows and UI.

text: string;
fontFamily: string;

A CSS family list: 'Georgia, serif'. A name may be a Font resource (the file name without its extension). While that face loads, and if it fails, it is left out and the rest of the list is used; the text redraws once when the face finishes loading.

readonly resolvedFontFamily: string;

The family list actually given to the canvas, after a missing Font resource has been left out.

fontSize: number;
fontWeight: string;

CSS weight: 'normal', 'bold', '300'…

color: NColorValue;
outlineColor: NColorValue;
outlineWidth: number;

0 for none.

align: 'left' | 'center' | 'right';
lineHeight: number;

Distance between lines; 0 means 1.2 × fontSize.

maxWidth: number;

Wrap width; 0 means lines break only at newlines.

readonly width: number;

The drawn size in world units (0 until first drawn).

readonly height: number;
readonly needsRedraw: boolean;
hitTestByPoint(x: number, y: number): boolean;
SetText(value: string): void;
GetText(): string;
SetColor(value: NColorValue): void;
GetColor(): NColorValue;
TileRendererinterface 19 commands
interface TileRenderer extends Component

A grid of image tiles.

lighting: NLighting;

Whether a camera with Camera Effects lighting lights it: 'lit' (the default) or 'unlit', for glows and UI.

gridColor: NColorValue;
tileColor: NColorValue;
offsetX: number;
offsetY: number;
tileSizeX: number;
tileSizeY: number;
gridSizeX: number;
gridSizeY: number;
readonly totalSizeX: number;
readonly totalSizeY: number;
GetTotalSizeX(): number;

2018 names of totalSizeX / totalSizeY: the layer's size in pixels.

GetTotalSizeY(): number;
setTileAt(tileX: number, tileY: number, worldX: number, worldY: number, imageResource: NImageResource): void;

Puts the image region (worldX, worldY) of imageResource at tile (tileX, tileY).

isTileSolid(tileX: number, tileY: number): boolean;

Whether the tile collides. Solid tiles are merged into boxes for physics (at Play) and Physics queries.

setTileSolid(tileX: number, tileY: number, solid: boolean): boolean;

False when there is no tile there. Changing it while playing affects queries, not the physics world.

readonly solidRects: ReadonlyArray<{ x: number; y: number; width: number; height: number }>;

The solid tiles merged into rectangles, in local units.

updateBidimensionalData(): void;
hitTestByPoint(x: number, y: number): boolean;
UIRootinterface 3 commands
interface UIRoot extends Component

UI Root (ComponentType.UIRoot): keeps its GameObject pinned to the first scene camera's view, so its children form a HUD that stays put on screen, drawn after the world.

anchor: 'top-left' | 'top' | 'top-right' | 'left' | 'center' | 'right' | 'bottom-left' | 'bottom' | 'bottom-right';
offsetX: number;

In camera units from the anchor, +y down.

offsetY: number;

Made from the editor’s we-scripting-api.d.ts file (version 7c9eecb0b).