Class: Engine
MMPX — backend-agnostic ECS for playable ads. Public surface only; files inside src/MMPX/ import each other by relative path (going through the barrel breaks tree-shaking and risks cycles). Flat re-exports for the names you reach for constantly.
Implements
Constructors
Constructor
ts
new Engine(options): Engine;Parameters
| Parameter | Type |
|---|---|
options | EngineOptions |
Returns
Engine
Methods
GetActiveScene()
ts
GetActiveScene(): Scene | null;Returns
Scene | null
GetAdAdapter()
ts
GetAdAdapter(): IAdAdapter;Returns
Implementation of
GetAssetLoader()
ts
GetAssetLoader(): IAssetLoader;Returns
Implementation of
GetAudio()
ts
GetAudio(): IAudio | null;Returns
IAudio | null
Implementation of
GetAvgFpsCount()
ts
GetAvgFpsCount(): number;Returns
number
Implementation of
GetAvgTpsCount()
ts
GetAvgTpsCount(): number;Returns
number
Implementation of
GetBackend()
ts
GetBackend(): IBackend;Returns
GetBuildInfo()
ts
GetBuildInfo(): Readonly<BuildInfo>;Returns
Readonly<BuildInfo>
GetComponentClasses()
ts
GetComponentClasses(): readonly unknown[];Every component class this build carries (core and features').
Returns
readonly unknown[]
GetCurrentProject()
ts
GetCurrentProject(): IProject | null;Returns
IProject | null
Implementation of
GetDebugDrawSystem()
ts
GetDebugDrawSystem(): DebugDrawSystem | null;Returns
DebugDrawSystem | null
GetDeltaTime()
ts
GetDeltaTime(): number;Returns
number
GetFeatures()
ts
GetFeatures(): readonly EngineFeature[];The optional features this engine was built with.
Returns
readonly EngineFeature[]
GetFixedStep()
ts
GetFixedStep(): number;Returns
number
GetGameTime()
ts
GetGameTime(): number;Returns
number
GetInput()
ts
GetInput(): IInput;Returns
Implementation of
GetLastFrameTime()
ts
GetLastFrameTime(): number;Returns
number
Implementation of
GetLastFrameTimeMs()
ts
GetLastFrameTimeMs(): number;Returns
number
GetLastRenderPasses()
ts
GetLastRenderPasses(): number;One per active camera, not a GPU draw-call count.
Returns
number
GetLastRenderTimeMs()
ts
GetLastRenderTimeMs(): number;Returns
number
GetLastTickTime()
ts
GetLastTickTime(): number;Returns
number
Implementation of
GetLastTickTimeMs()
ts
GetLastTickTimeMs(): number;Timings and the FPS / TPS averages are measured in dev builds only — 0 in production.
Returns
number
GetLocalization()
ts
GetLocalization(): Localization;Outlives scenes and sessions: the player's language stays picked across Play / scene loads.
Returns
Implementation of
GetPerfOverlaySystem()
ts
GetPerfOverlaySystem(): PerfOverlaySystem | null;Returns
PerfOverlaySystem | null
GetPerfProfiler()
ts
GetPerfProfiler(): PerfProfiler | null;Dev-only per-system timing. Null in production builds. Enable via engine.GetPerfProfiler()?.SetEnabled(true), then read GetFrames() / GetAverages().
Returns
PerfProfiler | null
GetPhysics2D()
ts
GetPhysics2D():
| Physics2DSystem
| null;2D physics (Game.physics2D wraps it). A new backend or a changed pixels-per-metre rebuilds the running world; null switches physics off. null without the 2D physics feature (EngineOptions.features).
Returns
| Physics2DSystem | null
GetPhysicsTimeMs()
ts
GetPhysicsTimeMs(): number;Per-frame ms (smoothed over ~20 frames) in 2D physics (step, body sync, poses) and in game code (script hooks, events, scheduled callbacks, animation events). Script time spent inside physics (contact callbacks) counts as scripts.
Returns
number
GetRenderer()
ts
GetRenderer(): IRenderer;Returns
Implementation of
GetRendererStats()
ts
GetRendererStats(): IRendererStats | null;Returns
IRendererStats | null
GetScheduler()
ts
GetScheduler(): SystemScheduler;Returns
GetScriptTimeMs()
ts
GetScriptTimeMs(): number;Returns
number
GetStatsOverlaySystem()
ts
GetStatsOverlaySystem(): StatsOverlaySystem | null;Returns
StatsOverlaySystem | null
GetTargetFps()
ts
GetTargetFps(): number;Returns
number
Implementation of
GetTargetTps()
ts
GetTargetTps(): number;Returns
number
Implementation of
GetTimeScale()
ts
GetTimeScale(): number;Game clock — see Game.time.
Returns
number
Implementation of
GetUnscaledGameTime()
ts
GetUnscaledGameTime(): number;Returns
number
GetUpdateCount()
ts
GetUpdateCount(): number;Returns
number
HasFeature()
ts
HasFeature(id): boolean;Parameters
| Parameter | Type |
|---|---|
id | string |
Returns
boolean
HasViewOverride()
ts
HasViewOverride(): boolean;Frames render through an editor view instead of the scene's cameras (Engine.SetViewOverride).
Returns
boolean
Implementation of
Init()
ts
Init(rendererData): Promise<boolean>;Parameters
| Parameter | Type |
|---|---|
rendererData | RendererData |
Returns
Promise<boolean>
Implementation of
IsDebugDrawEnabled()
ts
IsDebugDrawEnabled(): boolean;Returns
boolean
IsHeldByHost()
ts
IsHeldByHost(): boolean;Held by the ad container (paused by the network, or not on screen) — see m_networkPaused.
Returns
boolean
IsInitialized()
ts
IsInitialized(): boolean;Returns
boolean
Implementation of
IsPaused()
ts
IsPaused(): boolean;Returns
boolean
Implementation of
IsPerfOverlayEnabled()
ts
IsPerfOverlayEnabled(): boolean;Returns
boolean
IsSimulationEnabled()
ts
IsSimulationEnabled(): boolean;False in edit mode — update phases are skipped (Engine.SetSimulationEnabled).
Returns
boolean
Implementation of
IsStatsEnabled()
ts
IsStatsEnabled(): boolean;Returns
boolean
RegisterSystem()
ts
RegisterSystem(system): void;Parameters
| Parameter | Type |
|---|---|
system | ISystem |
Returns
void
Implementation of
RenderCamerasToCanvas()
ts
RenderCamerasToCanvas(width, height): HTMLCanvasElement | null;The screen as the scene's cameras draw it, at width × height, into a new canvas — each screen camera rendered offscreen into its viewport rect and laid over the ones before it. The live view is untouched (the editor's project thumbnail). Null without OffscreenCapability.
Parameters
| Parameter | Type |
|---|---|
width | number |
height | number |
Returns
HTMLCanvasElement | null
RenderToCanvas()
ts
RenderToCanvas(
config,
width,
height
): HTMLCanvasElement | null;Renders the active scene through config into an offscreen canvas (thumbnails, previews), using what the render systems last pushed — so call it after a rendered frame. Null when the backend has no OffscreenCapability.
Parameters
| Parameter | Type |
|---|---|
config | CameraConfig |
width | number |
height | number |
Returns
HTMLCanvasElement | null
Run()
ts
Run(project): boolean;Parameters
| Parameter | Type |
|---|---|
project | IProject |
Returns
boolean
Implementation of
SetBackend()
ts
SetBackend(backend): Promise<void>;Swap RENDERER backends at runtime. Tears down the current one, stands up the new one, and notifies every registered system via OnRendererChanged so they drop cached handles and re-acquire capabilities. ECS state is preserved — drawables reappear on the next tick. Audio is on its own backend axis and is left untouched.
Parameters
| Parameter | Type |
|---|---|
backend | IBackend |
Returns
Promise<void>
Implementation of
SetBuildInfo()
ts
SetBuildInfo(info): void;The editor's Play (the active build profile); a build sets it once through EngineOptions.build.
Parameters
| Parameter | Type |
|---|---|
info | Partial<BuildInfo> |
Returns
void
SetCameraPreview()
ts
SetCameraPreview(camera, rect?): void;Editor hook — after the frame's passes, also draw camera's view into rect (canvas pixels): the Scene view's camera preview inset. null removes it.
Parameters
| Parameter | Type | Default value |
|---|---|---|
camera | number | null | undefined |
rect | CameraPreviewRect | null | null |
Returns
void
SetDebugDrawEnabled()
ts
SetDebugDrawEnabled(enabled): void;Dev overlays. All Set/Get/Is variants below are no-ops or return null in production because the backing systems are never constructed there.
Parameters
| Parameter | Type |
|---|---|
enabled | boolean |
Returns
void
SetOverlayCamera()
ts
SetOverlayCamera(camera): void;Editor hook — the camera whose view the debug / editor overlay is drawn through when the scene's own cameras render (the Game view): the one showing the selection. null = the last pass.
Parameters
| Parameter | Type |
|---|---|
camera | number | null |
Returns
void
SetParticlePreview()
ts
SetParticlePreview(roots, speed?): void;Editor hook — in edit mode, play the particle systems at and under roots (the selection) at speed; null / empty stops and clears them. No effect while the game runs.
Parameters
| Parameter | Type | Default value |
|---|---|---|
roots | readonly number[] | null | undefined |
speed | number | 1 |
Returns
void
SetPaused()
ts
SetPaused(paused): void;Editor hook — freezes the update phases without detaching their systems (unlike SetSimulationEnabled(false), scripts keep their state). StepFrame runs exactly one update.
Parameters
| Parameter | Type |
|---|---|
paused | boolean |
Returns
void
SetPerfOverlayEnabled()
ts
SetPerfOverlayEnabled(enabled): void;Parameters
| Parameter | Type |
|---|---|
enabled | boolean |
Returns
void
SetPhysics2DBackend()
ts
SetPhysics2DBackend(backend): void;Parameters
| Parameter | Type |
|---|---|
backend | IPhysics2DBackend | null |
Returns
void
SetPhysics2DSettings()
ts
SetPhysics2DSettings(settings): void;Parameters
| Parameter | Type |
|---|---|
settings | Partial<Physics2DSettings> |
Returns
void
SetSimulationEnabled()
ts
SetSimulationEnabled(enabled): void;Editor hook — false runs render phases only (scene draws, nothing simulates).
Parameters
| Parameter | Type |
|---|---|
enabled | boolean |
Returns
void
SetStatsEnabled()
ts
SetStatsEnabled(enabled): void;Parameters
| Parameter | Type |
|---|---|
enabled | boolean |
Returns
void
SetTargetFps()
ts
SetTargetFps(fps): void;Most frames drawn per second; 0 (or anything not a positive number) draws every display refresh.
Parameters
| Parameter | Type |
|---|---|
fps | number |
Returns
void
SetTargetTps()
ts
SetTargetTps(tps): void;Fixed updates per second — the update phases' step, so also the physics step.
Parameters
| Parameter | Type |
|---|---|
tps | number |
Returns
void
SetTimeScale()
ts
SetTimeScale(scale): void;Parameters
| Parameter | Type |
|---|---|
scale | number |
Returns
void
SetViewOverride()
ts
SetViewOverride(config, stackCameras?): void;Editor hook — render through config instead of the scene's cameras; null restores them. stackCameras keeps the cameras' layering under that view: their depth order and culling masks, one pass each (renderStackedOverride).
Parameters
| Parameter | Type | Default value |
|---|---|---|
config | CameraConfig | null | undefined |
stackCameras | boolean | false |
Returns
void
StepFrame()
ts
StepFrame(): void;Returns
void
Stop()
ts
Stop(): void;Returns
void
Implementation of
TextureToCanvas()
ts
TextureToCanvas(assetId): HTMLCanvasElement | null;A loaded texture asset's current pixels — e.g. what a camera last drew into a render texture.
Parameters
| Parameter | Type |
|---|---|
assetId | string |
Returns
HTMLCanvasElement | null
UnregisterSystem()
ts
UnregisterSystem(system): void;Parameters
| Parameter | Type |
|---|---|
system | ISystem |
Returns
void