Skip to content

Configuration ​

StartBare options ​

Pass options as the second argument to StartBare:

StartBare(sceneClass, options?): Promise<Scene> starts the engine and resolves with the initial scene after startup.

ts
import { Color, StartBare } from 'bare-engine';

StartBare(Game, {
    backgroundColor: new Color(30, 30, 40, 255),
    resolution: { width: 1280, height: 720 },
});
OptionDefaultDescription
backgroundColorrenderer startup colorCanvas background color, as a Color. Set it explicitly for a predictable appearance.
resolutionfull windowRender size, see below.
antiAliastrueSmooth edges.
textureFilterLINEARUse NEAREST for pixel art.
roundPixelsfalseSnap rendering to whole pixels.
premultipliedAlphatrueWebGL context alpha representation, passed to the renderer on startup.
scaleModeCanvasScaleMode.CanvasItemHow canvas scaling affects the render buffer; see below.
fixedTimestep1/60Seconds per fixed update.
freezeOnUnfocustruePause when the tab loses focus.
multiTouchfalseAccept more than one touch at once.
gameObjectPoolSize50Default size of object pools.
showEditorButtonautomatictrue: keep the button visible when a level is loaded, including with the extension connected. false: hide it. Omitted: hide it when the extension connects. Development only.
editorButtonPosition{ x: 0, y: 0 }Normalized position and pivot, as { x: number, y: number }. { x: 1, y: 0 } anchors it at the top right. Development only; see Level editor in production.
debugKeysE, P, R, L, CKeyboard shortcuts during development. See Debug keys.

Resolution ​

See Resolution & Pixel Art for common setups.

FieldDescription
width, heightFixed game size in game units.
scaleA fixed CSS scale, or CanvasScale.Fit to fit the window.
positionCanvasPosition.Center or CanvasPosition.TopLeft.
integerScaleOnly scale by whole numbers, for crisp pixel art.
pixelScaleFill the window, but render at a lower resolution so everything appears pixelScale times bigger. Overrides width, height and scale.

Debug keys ​

The default keys and how to change them are listed under Debugging. They're removed from production builds.

Scene options ​

A scene's constructor passes options to super:

ts
import { Scene } from 'bare-engine';
import settingsData from '../public/data/settingsData.json';

export class HUD extends Scene
{
    constructor()
    {
        super({ settingsData, UI: true, persistent: true });
    }
}
OptionDefaultDescription
settingsDatabuilt-in defaultsThe scene's settings: prefabs, layers, animations.
UIfalseNot moved by a camera, drawn in screen space, and kept above non-UI scenes.
resizefalseWhen the window size changes, move every object so it keeps its relative place on screen.
persistentfalseKeep the scene when bare.scene.Goto clears the others.

super(settingsData) is shorthand for super({ settingsData }).

package.json ​

Build settings such as gameId, firstLevelLoad and stripGeneratedAssets go under bareEngine in your project's package.json. See package.json Options for the full list.

Bare Engine is open source under the MIT license.