Interface

KAPLAYOpt

:

KAPLAY configurations.

group Start

width

?: number

Width of game.

height

?: number

Height of game.

scale

?: number

Pixel scale / size.

letterbox

?: boolean

Keep aspect ratio and leave black bars on remaining spaces.

debug

?: boolean

If register debug buttons (default true)

debugKey

?: Key

Key that toggles debug mode

font

?: string

Default font (defaults to "monospace").

pixelDensity

?: number

Device pixel scale (defaults to 1, high pixel density will hurt performance).

since v3000.0

crisp

?: boolean

Disable antialias and enable sharp pixel display. If you see rendering artifacts, set pixelDensity param to Math.min(devicePixelRatio, 2) and scale to FHD resolution (e.g. 960x540 would need scale 2). Will result in up to 4K.

canvas

?: HTMLCanvasElement

The canvas DOM element to use. If empty will create one.

root

?: HTMLElement

The container DOM element to insert the canvas if created. Defaults to document.body.

background

?: RGBValue | RGBAValue | string

Background color. E.g. [ 0, 0, 255 ] for solid blue background, or [ 0, 0, 0, 0 ] for transparent background. Accepts RGB value array or string hex codes.

texFilter

?: TexFilter

Default texture filter.

logMax

?: number

How many log messages can there be on one screen (default 8).

logTime

?: number

How many seconds log messages stay on screen (default 4).

since v3000.1

hashGridSize

?: number

Size of the spatial hash grid for collision detection (default 64).

since v3000.0

touchToMouse

?: boolean

If translate touch events as mouse clicks (default true).

loadingScreen

?: boolean

If KAPLAY should render a default loading screen when assets are not fully ready (default true).

since v3000.0

backgroundAudio

?: boolean

If pause audio when tab is not active (default false).

since v3000.0

gamepads

?: Record<string, GamepadDef>

Custom gamepad definitions (see gamepad.json for reference of the format).

since v3000.0

buttons

?: TButtonDef

Defined buttons for input binding.

since v30010

maxFPS

?: number

Limit framerate to an amount per second.

since v3000.0

focus

?: boolean

If focus on the canvas on start (default true).

since v3001.0

global

?: boolean

If import all KAPLAY functions to global (default true).

plugins

?: TPlugin

List of plugins to import.

burp

?: boolean

Enter burp mode.

tagComponentIds

?: boolean

Make components ids be added as tags. That means .is() will return true for components with that id.

default true

spriteAtlasPadding

?: number

Padding used when adding sprites to texture atlas.

default 0

inspectOnlyActive

?: boolean

If the debug inspect view should ignore objects that are paused when choosing the object to show the inspect view on.

default false

experimental

narrowPhaseCollisionAlgorithm

?: string

Which strategy to use for narrow phase collision, gjk or sat

default "gjk"

loadTimeout

?: number

Timeout (in milliseconds) at which other loaders waiting on sprites will give up and throw an error. Currently this is only used by .

default 3000

kaplay logo

Components