Settings

LittleJS Engine Settings

  • All settings for the engine are here

Members

(static) cameraAngle :number

Rotation angle of camera in world space

Type:
  • number

(static) cameraPos :Vector2

Position of camera in world space

Type:
  • Vector2
Default Value
  • Vector2()

(static) cameraScale :number

Scale of camera in world space

Type:
  • number
Default Value
  • 32

(static) canvasClearColor :Color

Color to clear the canvas to before render, does not clear if alpha is 0

Type:
  • Color

(static) canvasColorTiles :boolean

Enable applying color to tiles when using canvas2d

  • This is slower but should be the same as WebGL rendering
Type:
  • boolean
Default Value
  • true

(static) canvasFixedSize :Vector2

Fixed size of the canvas, if enabled canvas size never changes

  • you may also need to set mainCanvasSize if using screen space coords in startup
Type:
  • Vector2
Default Value
  • Vector2()

(static) canvasMaxAspect :number

Maximum aspect ratio of the canvas (width/height), unused if 0 Can be used with canvasMinAspect to limit aspect ratio

Type:
  • number

(static) canvasMaxSize :Vector2

The max size of the canvas, centered if window is larger

Type:
  • Vector2
Default Value
  • Vector2(1920,1080)

(static) canvasMinAspect :number

Minimum aspect ratio of the canvas (width/height), unused if 0 Can be used with canvasMaxAspect to limit aspect ratio

Type:
  • number

(static) canvasPixelRatio :number|undefined

Scale factor applied to the canvas backing store for native-resolution rendering. Pass 1 for no scaling, a number for an explicit ratio, or undefined to track devicePixelRatio each frame.

Type:
  • number | undefined
Default Value
  • 1

(static) canvasPixelated :boolean

Use nearest canvas scaling for more pixelated look

  • If enabled sets css image-rendering:pixelated
Type:
  • boolean

(static) enablePhysicsSolver :boolean

Enable physics solver for collisions between objects

Type:
  • boolean
Default Value
  • true

(static) engineManualStep :boolean

Disables the automatic requestAnimationFrame loop so the engine only advances when engineStep is called, for tests and frame-stepping tools

Type:
  • boolean

(static) fontDefault :string

Default font used for text rendering

Type:
  • string
Default Value
  • arial

(static) gamepadAxisFilterEnable :boolean

If true, axes that do not rest near center are ignored on gamepads without standard mapping. Steering wheels and flight sticks report pedal and throttle axes that rest at full deflection, which otherwise reads as a stick held down.

Type:
  • boolean
Default Value
  • true

(static) gamepadDirectionEmulateStick :boolean

If true, the dpad input is also routed to the left analog stick (for better accessibility)

Type:
  • boolean
Default Value
  • true

(static) gamepadsEnable :boolean

Should gamepads be allowed

Type:
  • boolean
Default Value
  • true

(static) glCircleSides :number

How many sided poly to use when drawing circles and ellipses with WebGL

Type:
  • number
Default Value
  • 32

(static) glEnable :boolean

Enable WebGL accelerated rendering

Type:
  • boolean
Default Value
  • true

(static) gravity :Vector2

How much gravity to apply to objects, negative Y is down

Type:
  • Vector2

(static) headlessMode :boolean

Disables all rendering, audio, and input for servers

Type:
  • boolean

(static) inputWASDEmulateDirection :boolean

If true the WASD keys are also routed to the direction keys (for better accessibility)

Type:
  • boolean
Default Value
  • true

(static) medalDisplaySize :Vector2

Size of medal display

Type:
  • Vector2
Default Value
  • Vector2(640,80)

(static) medalDisplaySlideTime :number

How quickly to slide on/off medals in seconds

Type:
  • number
Default Value
  • 0.5

(static) medalDisplayTime :number

How long to show medals for in seconds

Type:
  • number
Default Value
  • 5

(static) medalsPreventUnlock :boolean

Set to stop medals from being unlockable (like if cheats are enabled)

Type:
  • boolean

(static) objectDefaultAngleDamping :number

How much to slow angular velocity each frame (0-1)

Type:
  • number
Default Value
  • 1

(static) objectDefaultDamping :number

How much to slow velocity by each frame (0-1)

Type:
  • number
Default Value
  • 1

(static) objectDefaultFriction :number

How much to slow when touching (0-1)

Type:
  • number
Default Value
  • 0.8

(static) objectDefaultMass :number

Default object mass for collision calculations (how heavy objects are)

Type:
  • number
Default Value
  • 1

(static) objectDefaultRestitution :number

How much to bounce when a collision occurs (0-1)

Type:
  • number

(static) objectMaxSpeed :number

Clamp max speed to avoid fast objects missing collisions

Type:
  • number
Default Value
  • 1

(static) particleEmitRateScale :number

Scales emit rate of particles, useful for low graphics mode (0 disables particle emitters)

Type:
  • number
Default Value
  • 1

(static) showSplashScreen :boolean

Enable to show the LittleJS splash screen on startup

Type:
  • boolean

(static) soundDefaultRange :number

Default range where sound no longer plays

Type:
  • number
Default Value
  • 40

(static) soundDefaultTaper :number

Default range percent to start tapering off sound (0-1)

Type:
  • number
Default Value
  • 0.7

(static) soundEnable :boolean

All audio code can be disabled and removed from build

Type:
  • boolean
Default Value
  • true

(static) soundVolume :number

Volume scale to apply to all sound, music and speech Use setSoundVolume to also update the audio master gain immediately

Type:
  • number
Default Value
  • 0.3

(static) textureSheetPadding :number

Default padding pixels around each frame packed by loadSprite

Type:
  • number
Default Value
  • 1

(static) textureSheetSize :number

Width and height in pixels of texture sheets created by loadSprite

Type:
  • number
Default Value
  • 2048

(static) tileDefaultBleed :number

Default amount of pixels smaller to draw tiles to prevent neighbor bleeding

Type:
  • number

(static) tileDefaultPadding :number

Default padding pixels around tiles

Type:
  • number

(static) tileDefaultSize :Vector2

Default size of tiles in pixels

Type:
  • Vector2
Default Value
  • Vector2(16,16)

(static) tilesPixelated :boolean

Disables texture filtering for crisper pixel art

  • Leave true for pixel art so sprites stay sharp when scaled (uses NEAREST filtering)
  • Set false for smooth/high-resolution art to enable bilinear filtering and mipmaps
Type:
  • boolean
Default Value
  • true

(static) timeScale :number

Scale applied to engine time, can be used for slow motion or fast forward

  • 1 is normal speed, 2 is double speed, 0.5 is half speed
  • 0 freezes the simulation without setting the paused flag
  • Should be >= 0; stacks multiplicatively with the debug +/- shortcut
Type:
  • number
Default Value
  • 1

(static) touchGamepadAlpha :number

Transparency of touch gamepad overlay

Type:
  • number
Default Value
  • 0.3

(static) touchGamepadAnalog :boolean

True if touch gamepad should be analog stick or false to use if 8 way dpad

Type:
  • boolean
Default Value
  • true

(static) touchGamepadButtonCount :number

Number of buttons on the right side of the touch gamepad (0-4), using gamepad buttons 0-3

  • A count of 1 is a single large button (the size of a stick)
  • Ignored when touchGamepadRightStick is set (the right side is a stick instead)
Type:
  • number
Default Value
  • 4

(static) touchGamepadCenterButtonSize :number

Size of center button if touch gamepad should have start button in the center

  • Prevents activating when pressed near virtual stick or face buttons
  • When the game is paused, any touch will press the button
  • Measured in viewport CSS pixels
Type:
  • number

(static) touchGamepadDisplayTime :number

How long to display the touch gamepad on screen in seconds, set to 0 to always display

Type:
  • number
Default Value
  • 3

(static) touchGamepadEnable :boolean

True if touch gamepad should appear on mobile devices

  • Supports left analog stick, 4 face buttons and start button (button 9)
  • setTouchGamepadButtonCount(1) to use face buttons as right analog stick
  • Analog stick buttons 10 and 11 are also activated when virtual sticks are touched
  • Rendered as a full-viewport HTML/SVG overlay, so controls may sit outside the game canvas
Type:
  • boolean

(static) touchGamepadFloating :boolean

True if touch gamepad directional controls should float to where you press

  • Only affects analog sticks and dpads, not face buttons
  • Directional controls re-anchor to where you press within the bottom ~60% of their screen half; the top ~40% passes through to the game
  • The right side floats only when it acts as the right analog stick (touchGamepadRightStick is set)
  • A center button (touchGamepadCenterButtonSize) still works since it ignores touches near the sticks
Type:
  • boolean

(static) touchGamepadLeftButtonCount :number

Number of buttons on the left side of the touch gamepad (0-4), using gamepad buttons 4-7

  • Only used when touchGamepadLeftStick is false (otherwise the left side is a stick)
  • A count of 1 is a single large button (the size of a stick)
Type:
  • number

(static) touchGamepadLeftStick :boolean

True if the touch gamepad should have a left analog stick (or dpad)

  • When false, the left side is face buttons (touchGamepadLeftButtonCount) or nothing
Type:
  • boolean
Default Value
  • true

(static) touchGamepadPassthrough :boolean

True if touches outside the gamepad controls should still drive mouse/touch input

  • When false (the default), enabling the touch gamepad suppresses touch-to-mouse input entirely
  • Set true to also pass touches outside the controls through to the game as mouse/touch input
  • Touches on the gamepad controls never drive the mouse regardless of this setting
Type:
  • boolean

(static) touchGamepadRightStick :boolean

True if the touch gamepad right side should be an analog stick (or dpad) instead of face buttons

  • When set, touchGamepadButtonCount is ignored and the right side is a stick
  • Uses an analog stick when touchGamepadAnalog is true, otherwise an 8 way dpad
Type:
  • boolean

(static) touchGamepadSize :number

Size of virtual gamepad for touch devices in viewport CSS pixels

Type:
  • number
Default Value
  • 100

(static) touchGamepadVibration :number

Duration in ms to vibrate when a touch gamepad face button or start button is pressed

  • Set to 0 to disable, also requires vibrateEnable and hardware support (ignored on iOS)
Type:
  • number

(static) touchInputEnable :boolean

True if touch input is enabled for mobile devices

  • Touch events will be routed to mouse events
Type:
  • boolean
Default Value
  • true

(static) vibrateEnable :boolean

Allow vibration hardware if it exists

Type:
  • boolean
Default Value
  • true

Methods

(static) setCameraAngle(angle)

Set angle of camera in world space

Parameters:
NameTypeDescription
anglenumber

(static) setCameraPos(pos)

Set position of camera in world space

Parameters:
NameTypeDescription
posVector2

(static) setCameraScale(scale)

Set scale of camera in world space

Parameters:
NameTypeDescription
scalenumber

(static) setCanvasClearColor(color)

Set color to clear the canvas to before render, does not clear if alpha is 0

Parameters:
NameTypeDescription
colorColor

(static) setCanvasColorTiles(colorTiles)

Set if tiles should be colorized when using canvas2d This can be slower but results should look nearly identical to WebGL rendering It can be enabled/disabled at any time Optimized for performance, and will use faster method if color is white or untextured

Parameters:
NameTypeDescription
colorTilesboolean

(static) setCanvasFixedSize(size)

Set fixed size of the canvas

Parameters:
NameTypeDescription
sizeVector2

(static) setCanvasMaxAspect(aspect)

Set maximum aspect ratio of the canvas (width/height), unused if 0

Parameters:
NameTypeDescription
aspectnumber

(static) setCanvasMaxSize(size)

Set max size of the canvas

Parameters:
NameTypeDescription
sizeVector2

(static) setCanvasMinAspect(aspect)

Set minimum aspect ratio of the canvas (width/height), unused if 0

Parameters:
NameTypeDescription
aspectnumber

(static) setCanvasPixelRatio(pixelRatioopt)

Set the canvas pixel ratio. Pass a number for an explicit ratio, or call with no argument to track devicePixelRatio each frame.

Parameters:
NameTypeAttributesDescription
pixelRationumber<optional>

(static) setCanvasPixelated(pixelated)

Use nearest scaling algorithm for canvas for more pixelated look

Parameters:
NameTypeDescription
pixelatedboolean

(static) setEnablePhysicsSolver(enable)

Set if collisions between objects are enabled

Parameters:
NameTypeDescription
enableboolean

(static) setEngineManualStep(enableopt)

Set if the engine only advances when engineStep is called Must be set before engineInit

Parameters:
NameTypeAttributesDefaultDescription
enableboolean<optional>
true

(static) setFontDefault(font)

Set default font used for text rendering

Parameters:
NameTypeDescription
fontstring

(static) setGLCircleSides(sides)

Set how many sided polygons to use when drawing circles and ellipses with WebGL

Parameters:
NameTypeDescription
sidesnumber

(static) setGLEnable(enable)

Set if WebGL rendering is enabled

Parameters:
NameTypeDescription
enableboolean

(static) setGamepadAxisFilterEnable(enable)

Set if axes that do not rest near center are ignored on non-standard gamepads

Parameters:
NameTypeDescription
enableboolean

(static) setGamepadDirectionEmulateStick(enable)

Set if the dpad input is also routed to the left analog stick

Parameters:
NameTypeDescription
enableboolean

(static) setGamepadsEnable(enable)

Set if gamepads are enabled

Parameters:
NameTypeDescription
enableboolean

(static) setGravity(newGravity)

Set how much gravity to apply to objects

Parameters:
NameTypeDescription
newGravityVector2

(static) setHeadlessMode(headless)

Set to disable rendering, audio, and input for servers

Parameters:
NameTypeDescription
headlessboolean

(static) setInputWASDEmulateDirection(enable)

Set if true the WASD keys are also routed to the direction keys

Parameters:
NameTypeDescription
enableboolean

(static) setMedalDisplaySize(size)

Set size of medal display

Parameters:
NameTypeDescription
sizeVector2

(static) setMedalDisplaySlideTime(time)

Set how quickly to slide on/off medals in seconds

Parameters:
NameTypeDescription
timenumber

(static) setMedalDisplayTime(time)

Set how long to show medals for in seconds

Parameters:
NameTypeDescription
timenumber

(static) setMedalsPreventUnlock(preventUnlock)

Set to stop medals from being unlockable

Parameters:
NameTypeDescription
preventUnlockboolean

(static) setObjectDefaultAngleDamping(damp)

Set how much to slow angular velocity each frame

Parameters:
NameTypeDescription
dampnumber

(static) setObjectDefaultDamping(damp)

Set how much to slow velocity by each frame

Parameters:
NameTypeDescription
dampnumber

(static) setObjectDefaultFriction(friction)

Set how much to slow when touching

Parameters:
NameTypeDescription
frictionnumber

(static) setObjectDefaultMass(mass)

Set default object mass for collision calculations

Parameters:
NameTypeDescription
massnumber

(static) setObjectDefaultRestitution(restitution)

Set how much to bounce when a collision occurs

Parameters:
NameTypeDescription
restitutionnumber

(static) setObjectMaxSpeed(speed)

Set max speed to avoid fast objects missing collisions

Parameters:
NameTypeDescription
speednumber

(static) setParticleEmitRateScale(scale)

Set to scales emit rate of particles

Parameters:
NameTypeDescription
scalenumber

(static) setShowSplashScreen(show)

Set if the LittleJS splash screen should be shown on startup

Parameters:
NameTypeDescription
showboolean

(static) setSoundDefaultRange(range)

Set default range where sound no longer plays

Parameters:
NameTypeDescription
rangenumber

(static) setSoundDefaultTaper(taper)

Set default range percent to start tapering off sound

Parameters:
NameTypeDescription
tapernumber

(static) setSoundEnable(enable)

Set to disable all audio code

Parameters:
NameTypeDescription
enableboolean

(static) setSoundVolume(volume)

Set volume scale to apply to all sound, music and speech

Parameters:
NameTypeDescription
volumenumber

(static) setTextureSheetPadding(padding)

Set default padding pixels around each frame packed by loadSprite

Parameters:
NameTypeDescription
paddingnumber

(static) setTextureSheetSize(size)

Set width and height in pixels of texture sheets created by loadSprite

Parameters:
NameTypeDescription
sizenumber

(static) setTileDefaultBleed(bleed)

Default amount of pixels smaller to draw tiles to prevent neighbor bleeding

Parameters:
NameTypeDescription
bleednumber

(static) setTileDefaultPadding(padding)

Default padding pixels around tiles

Parameters:
NameTypeDescription
paddingnumber

(static) setTileDefaultSize(size)

Set default size of tiles in pixels

Parameters:
NameTypeDescription
sizeVector2

(static) setTilesPixelated(pixelated)

Disables texture filtering for crisper pixel art

  • Leave true for pixel art; set false for smooth/high-resolution art
Parameters:
NameTypeDescription
pixelatedboolean

(static) setTimeScale(scale)

Set scale applied to engine time

Parameters:
NameTypeDescription
scalenumber

(static) setTouchGamepadAlpha(alpha)

Set transparency of touch gamepad overlay

Parameters:
NameTypeDescription
alphanumber

(static) setTouchGamepadAnalog(analog)

Set if touch gamepad should be analog stick or 8 way dpad

Parameters:
NameTypeDescription
analogboolean

(static) setTouchGamepadButtonCount(count)

Set number of buttons on the right side of the touch gamepad (0-4, gamepad buttons 0-3)

Parameters:
NameTypeDescription
countnumber

(static) setTouchGamepadCenterButtonSize(size)

Set if touch gamepad should have start button in the center

  • Set size to enable the center button
  • When the game is paused, any touch will press the button
Parameters:
NameTypeDescription
sizenumber

(static) setTouchGamepadDisplayTime(time)

Set how long to display the touch gamepad on screen in seconds, set to 0 to always display

Parameters:
NameTypeDescription
timenumber

(static) setTouchGamepadEnable(enable)

Set if touch gamepad should appear on mobile devices

Parameters:
NameTypeDescription
enableboolean

(static) setTouchGamepadFloating(floating)

Set if touch gamepad directional controls should float to where you press

Parameters:
NameTypeDescription
floatingboolean

(static) setTouchGamepadLeftButtonCount(count)

Set number of buttons on the left side of the touch gamepad (0-4, gamepad buttons 4-7)

  • Only used when touchGamepadLeftStick is false
Parameters:
NameTypeDescription
countnumber

(static) setTouchGamepadLeftStick(enable)

Set if the touch gamepad should have a left analog stick (or dpad)

Parameters:
NameTypeDescription
enableboolean

(static) setTouchGamepadPassthrough(passthrough)

Set if touches outside the gamepad controls should still drive mouse/touch input

Parameters:
NameTypeDescription
passthroughboolean

(static) setTouchGamepadRightStick(rightStick)

Set if the touch gamepad right side is an analog stick (or dpad) instead of face buttons

Parameters:
NameTypeDescription
rightStickboolean

(static) setTouchGamepadSize(size)

Set size of virtual gamepad for touch devices in pixels

Parameters:
NameTypeDescription
sizenumber

(static) setTouchGamepadVibration(ms)

Set duration in ms to vibrate when a touch gamepad face or start button is pressed (0 disables)

Parameters:
NameTypeDescription
msnumber

(static) setTouchInputEnable(enable)

Set if touch input is allowed

Parameters:
NameTypeDescription
enableboolean

(static) setVibrateEnable(enable)

Set to allow vibration hardware if it exists

Parameters:
NameTypeDescription
enableboolean