API

TypeScript API

Explore the class-first BornEngine API, ownership model, and public module map.

BornEngine applications start with one Game instance. The Game owns the native runtime and exposes services for rendering, input, audio, scenes, UI, mobile controls, and networking. Stateful resources receive that Game in their constructor and keep native identity private.

typescript
import { Colors, Game } from '@bornengine/engine';

class FieldTest extends Game {
  constructor() {
    super({ window: { title: 'Field test', width: 1280, height: 720 } });
  }

  protected override loop(deltaTime: number): void {
    this.scenes.update(deltaTime);
  }

  protected override render(): void {
    this.renderer.clear(Colors.SKYBLUE);
    super.render();
  }
}

new FieldTest().run();

Import from the root or a subpath

The package root is convenient for game code. Import from a subpath when you want the module boundary to be visible in a library or feature package:

typescript
import { Game } from '@bornengine/engine/core';
import { PhysicsWorld, SphereCollider } from '@bornengine/engine/physics';

const game = new Game();
const physics = new PhysicsWorld(game);
const ballShape = new SphereCollider(physics, 0.5);

Both paths expose the same supported classes and types. Internal FFI functions and numeric resource handles are not package exports.

Module map

ModuleImport pathOwned API
Core@bornengine/engine/coreGame, Window, Renderer, platform values
2D camera@bornengine/engine/camera2dCameraRig2D, Viewport2D, ParallaxLayer2D
Input@bornengine/engine/inputInputSystem, InputActionMap, serializable action data
Shapes@bornengine/engine/shapesRenderer drawing and pure collision helpers
Textures@bornengine/engine/texturesTexture, RenderTexture, ImageData
Assets@bornengine/engine/assetsAssetManager, texture cache, AssetGroup preload batches
Sprites@bornengine/engine/spritesSpriteSheet, SpriteRenderer, SpriteAnimation, SpriteAnimator, ParticleEmitter2D
Text@bornengine/engine/textFont
Audio@bornengine/engine/audioAudioSystem, Sound, Music, SoundManager, AudioListener2D, AudioEmitter2D
Storage@bornengine/engine/storagecreateGameStorage, versioned JSON saves and settings
Models@bornengine/engine/modelsModel, Mesh, Material, Animation
Scene@bornengine/engine/sceneSceneGraph, SceneNode
Game@bornengine/engine/gameGameObject, components, scenes, adapters
Physics@bornengine/engine/physicsPhysicsWorld, colliders, bodies, joints
Physics 2D@bornengine/engine/physics2dPhysicsWorld2D, PhysicsBody2D
Tilemaps@bornengine/engine/tilemapTilemap and tile collision data
World@bornengine/engine/worldWorldData, WorldInstance, prefab library
World2D@bornengine/engine/world2dVersioned 2D world validation, serialization, component registry, and loader
VFX@bornengine/engine/vfxParticleSystem, DecalSystem
Mobile@bornengine/engine/mobileTouchControls, joystick and button objects
UI@bornengine/engine/uiUi
Debug UI@bornengine/engine/debug-uiDebugUi, Game inspector options
Colyseus@bornengine/engine/colyseusColyseusClient, Room

Lifetime and failures

The current native runtime is process-global, so one Game may be active at a time. Check game.isReady and game.error after construction. Check isLoaded and error on resources that can fail to load. Call dispose() when an individual resource leaves gameplay; game.dispose() releases resources still owned by that game.