LittleJS Engine Settings
- All settings for the engine are here
- Source
Members
(static) cameraAngle :number
Rotation angle of camera in world space
- number
- Source
(static) cameraPos :Vector2
Position of camera in world space
- Vector2
- Default Value
- Vector2()
- Source
(static) cameraScale :number
Scale of camera in world space
- number
- Default Value
- 32
- Source
(static) canvasColorTiles :boolean
Enable applying color to tiles when using canvas2d
- This is slower but should be the same as WebGL rendering
- boolean
- Default Value
- true
- Source
(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
- Vector2
- Default Value
- Vector2()
- Source
(static) canvasMaxAspect :number
Maximum aspect ratio of the canvas (width/height), unused if 0 Can be used with canvasMinAspect to limit aspect ratio
- number
- Source
(static) canvasMaxSize :Vector2
The max size of the canvas, centered if window is larger
- Vector2
- Default Value
- Vector2(1920,1080)
- Source
(static) canvasMinAspect :number
Minimum aspect ratio of the canvas (width/height), unused if 0 Can be used with canvasMaxAspect to limit aspect ratio
- number
- Source
(static) canvasPixelated :boolean
Use nearest canvas scaling for more pixelated look
- If enabled sets css image-rendering:pixelated
- boolean
- Default Value
- true
- Source
(static) enablePhysicsSolver :boolean
Enable physics solver for collisions between objects
- boolean
- Default Value
- true
- Source
(static) fontDefault :string
Default font used for text rendering
- string
- Default Value
- arial
- Source
(static) gamepadDirectionEmulateStick :boolean
If true, the dpad input is also routed to the left analog stick (for better accessibility)
- boolean
- Default Value
- true
- Source
(static) gamepadsEnable :boolean
Should gamepads be allowed
- boolean
- Default Value
- true
- Source
(static) glCircleSides :number
How many sided poly to use when drawing circles and ellipses with WebGL
- number
- Default Value
- 32
- Source
(static) glEnable :boolean
Enable WebGL accelerated rendering
- boolean
- Default Value
- true
- Source
(static) gravity :Vector2
How much gravity to apply to objects, negative Y is down
- Vector2
- Source
(static) headlessMode :boolean
Disables all rendering, audio, and input for servers
- boolean
- Source
(static) inputWASDEmulateDirection :boolean
If true the WASD keys are also routed to the direction keys (for better accessibility)
- boolean
- Default Value
- true
- Source
(static) medalDisplaySize :Vector2
Size of medal display
- Vector2
- Default Value
- Vector2(640,80)
- Source
(static) medalDisplaySlideTime :number
How quickly to slide on/off medals in seconds
- number
- Default Value
- 0.5
- Source
(static) medalDisplayTime :number
How long to show medals for in seconds
- number
- Default Value
- 5
- Source
(static) medalsPreventUnlock :boolean
Set to stop medals from being unlockable (like if cheats are enabled)
- boolean
- Source
(static) objectDefaultAngleDamping :number
How much to slow angular velocity each frame (0-1)
- number
- Default Value
- 1
- Source
(static) objectDefaultDamping :number
How much to slow velocity by each frame (0-1)
- number
- Default Value
- 1
- Source
(static) objectDefaultFriction :number
How much to slow when touching (0-1)
- number
- Default Value
- 0.8
- Source
(static) objectDefaultMass :number
Default object mass for collision calculations (how heavy objects are)
- number
- Default Value
- 1
- Source
(static) objectDefaultRestitution :number
How much to bounce when a collision occurs (0-1)
- number
- Source
(static) objectMaxSpeed :number
Clamp max speed to avoid fast objects missing collisions
- number
- Default Value
- 1
- Source
(static) overlayCanvasPixelated :boolean
Use nearest canvas scaling for more pixelated look
- If enabled sets css image-rendering:pixelated
- This defaults to false because text looks better with smoothing
- boolean
- Source
(static) particleEmitRateScale :number
Scales emit rate of particles, useful for low graphics mode (0 disables particle emitters)
- number
- Default Value
- 1
- Source
(static) showSplashScreen :boolean
Enable to show the LittleJS splash screen on startup
- boolean
- Source
(static) soundDefaultRange :number
Default range where sound no longer plays
- number
- Default Value
- 40
- Source
(static) soundDefaultTaper :number
Default range percent to start tapering off sound (0-1)
- number
- Default Value
- 0.7
- Source
(static) soundEnable :boolean
All audio code can be disabled and removed from build
- boolean
- Default Value
- true
- Source
(static) soundVolume :number
Volume scale to apply to all sound, music and speech
- number
- Default Value
- 0.3
- Source
(static) tileFixBleedScale :number
How many pixels smaller to draw tiles to prevent bleeding from neighbors
- number
- Source
(static) tileSizeDefault :Vector2
Default size of tiles in pixels
- Vector2
- Default Value
- Vector2(16,16)
- Source
(static) tilesPixelated :boolean
Disables texture filtering for crisper pixel art
- boolean
- Default Value
- true
- Source
(static) touchGamepadAlpha :number
Transparency of touch gamepad overlay
- number
- Default Value
- 0.3
- Source
(static) touchGamepadAnalog :boolean
True if touch gamepad should be analog stick or false to use if 8 way dpad
- boolean
- Default Value
- true
- Source
(static) touchGamepadButtonCount :number
Number of buttons on touch gamepad (0-4), if 1 also acts as right analog stick
- number
- Default Value
- 4
- Source
(static) touchGamepadCenterButton :boolean
True if touch gamepad should have start button in the center
- When the game is paused, any touch will press the button
- This can function as a way to pause/unpause the game
- boolean
- Default Value
- true
- Source
(static) touchGamepadEnable :boolean
True if touch gamepad should appear on mobile devices
- Supports left analog stick, 4 face buttons and start button (button 9)
- boolean
- Source
(static) touchGamepadSize :number
Size of virtual gamepad for touch devices in pixels
- number
- Default Value
- 99
- Source
(static) touchInputEnable :boolean
True if touch input is enabled for mobile devices
- Touch events will be routed to mouse events
- boolean
- Default Value
- true
- Source
(static) vibrateEnable :boolean
Allow vibration hardware if it exists
- boolean
- Default Value
- true
- Source
Methods
(static) setCameraAngle(angle)
Set angle of camera in world space
| Name | Type | Description |
|---|---|---|
angle | number |
- Source
(static) setCameraPos(pos)
Set position of camera in world space
| Name | Type | Description |
|---|---|---|
pos | Vector2 |
- Source
(static) setCameraScale(scale)
Set scale of camera in world space
| Name | Type | Description |
|---|---|---|
scale | number |
- Source
(static) setCanvasClearColor(color)
Set color to clear the canvas to before render
| Name | Type | Description |
|---|---|---|
color | Color |
- Source
(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
| Name | Type | Description |
|---|---|---|
colorTiles | boolean |
- Source
(static) setCanvasFixedSize(size)
Set fixed size of the canvas
| Name | Type | Description |
|---|---|---|
size | Vector2 |
- Source
(static) setCanvasMaxAspect(aspect)
Set maximum aspect ratio of the canvas (width/height), unused if 0
| Name | Type | Description |
|---|---|---|
aspect | number |
- Source
(static) setCanvasMaxSize(size)
Set max size of the canvas
| Name | Type | Description |
|---|---|---|
size | Vector2 |
- Source
(static) setCanvasMinAspect(aspect)
Set minimum aspect ratio of the canvas (width/height), unused if 0
| Name | Type | Description |
|---|---|---|
aspect | number |
- Source
(static) setCanvasPixelated(pixelated)
Use nearest scaling algorithm for canvas for more pixelated look
- If enabled sets css image-rendering:pixelated
| Name | Type | Description |
|---|---|---|
pixelated | boolean |
- Source
(static) setEnablePhysicsSolver(enable)
Set if collisions between objects are enabled
| Name | Type | Description |
|---|---|---|
enable | boolean |
- Source
(static) setFontDefault(font)
Set default font used for text rendering
| Name | Type | Description |
|---|---|---|
font | string |
- Source
(static) setGLCircleSides(sides)
Set how many sided polygons to use when drawing circles and ellipses with WebGL
| Name | Type | Description |
|---|---|---|
sides | number |
- Source
(static) setGLEnable(enable)
Set if WebGL rendering is enabled
| Name | Type | Description |
|---|---|---|
enable | boolean |
- Source
(static) setGamepadDirectionEmulateStick(enable)
Set if the dpad input is also routed to the left analog stick
| Name | Type | Description |
|---|---|---|
enable | boolean |
- Source
(static) setGamepadsEnable(enable)
Set if gamepads are enabled
| Name | Type | Description |
|---|---|---|
enable | boolean |
- Source
(static) setGravity(newGravity)
Set how much gravity to apply to objects
| Name | Type | Description |
|---|---|---|
newGravity | Vector2 |
- Source
(static) setHeadlessMode(headless)
Set to disable rendering, audio, and input for servers
| Name | Type | Description |
|---|---|---|
headless | boolean |
- Source
(static) setInputWASDEmulateDirection(enable)
Set if true the WASD keys are also routed to the direction keys
| Name | Type | Description |
|---|---|---|
enable | boolean |
- Source
(static) setMedalDisplaySize(size)
Set size of medal display
| Name | Type | Description |
|---|---|---|
size | Vector2 |
- Source
(static) setMedalDisplaySlideTime(time)
Set how quickly to slide on/off medals in seconds
| Name | Type | Description |
|---|---|---|
time | number |
- Source
(static) setMedalDisplayTime(time)
Set how long to show medals for in seconds
| Name | Type | Description |
|---|---|---|
time | number |
- Source
(static) setMedalsPreventUnlock(preventUnlock)
Set to stop medals from being unlockable
| Name | Type | Description |
|---|---|---|
preventUnlock | boolean |
- Source
(static) setObjectDefaultAngleDamping(damp)
Set how much to slow angular velocity each frame
| Name | Type | Description |
|---|---|---|
damp | number |
- Source
(static) setObjectDefaultDamping(damp)
Set how much to slow velocity by each frame
| Name | Type | Description |
|---|---|---|
damp | number |
- Source
(static) setObjectDefaultFriction(friction)
Set how much to slow when touching
| Name | Type | Description |
|---|---|---|
friction | number |
- Source
(static) setObjectDefaultMass(mass)
Set default object mass for collision calculations
| Name | Type | Description |
|---|---|---|
mass | number |
- Source
(static) setObjectDefaultRestitution(restitution)
Set how much to bounce when a collision occurs
| Name | Type | Description |
|---|---|---|
restitution | number |
- Source
(static) setObjectMaxSpeed(speed)
Set max speed to avoid fast objects missing collisions
| Name | Type | Description |
|---|---|---|
speed | number |
- Source
(static) setOverlayCanvasPixelated(pixelated)
Use nearest scaling algorithm for canvas for more pixelated look
- If enabled sets css image-rendering:pixelated
- This defaults to false because text looks better with smoothing
| Name | Type | Description |
|---|---|---|
pixelated | boolean |
- Source
(static) setParticleEmitRateScale(scale)
Set to scales emit rate of particles
| Name | Type | Description |
|---|---|---|
scale | number |
- Source
(static) setShowSplashScreen(show)
Set if the LittleJS splash screen should be shown on startup
| Name | Type | Description |
|---|---|---|
show | boolean |
- Source
(static) setSoundDefaultRange(range)
Set default range where sound no longer plays
| Name | Type | Description |
|---|---|---|
range | number |
- Source
(static) setSoundDefaultTaper(taper)
Set default range percent to start tapering off sound
| Name | Type | Description |
|---|---|---|
taper | number |
- Source
(static) setSoundEnable(enable)
Set to disable all audio code
| Name | Type | Description |
|---|---|---|
enable | boolean |
- Source
(static) setSoundVolume(volume)
Set volume scale to apply to all sound, music and speech
| Name | Type | Description |
|---|---|---|
volume | number |
- Source
(static) setTileFixBleedScale(scale)
Set to prevent tile bleeding from neighbors in pixels
| Name | Type | Description |
|---|---|---|
scale | number |
- Source
(static) setTileSizeDefault(size)
Set default size of tiles in pixels
| Name | Type | Description |
|---|---|---|
size | Vector2 |
- Source
(static) setTilesPixelated(pixelated)
Disables texture filtering for crisper pixel art
| Name | Type | Description |
|---|---|---|
pixelated | boolean |
- Source
(static) setTouchGamepadAlpha(alpha)
Set transparency of touch gamepad overlay
| Name | Type | Description |
|---|---|---|
alpha | number |
- Source
(static) setTouchGamepadAnalog(analog)
Set if touch gamepad should be analog stick or 8 way dpad
| Name | Type | Description |
|---|---|---|
analog | boolean |
- Source
(static) setTouchGamepadButtonCount(count)
Set number of buttons on touch gamepad (0-4), if 1 also acts as right analog stick
| Name | Type | Description |
|---|---|---|
count | number |
- Source
(static) setTouchGamepadCenterButton(enable)
True if touch gamepad should have start button in the center
- This can function as a way to pause/unpause the game
| Name | Type | Description |
|---|---|---|
enable | boolean |
- Source
(static) setTouchGamepadEnable(enable)
Set if touch gamepad should appear on mobile devices
| Name | Type | Description |
|---|---|---|
enable | boolean |
- Source
(static) setTouchGamepadSize(size)
Set size of virtual gamepad for touch devices in pixels
| Name | Type | Description |
|---|---|---|
size | number |
- Source
(static) setTouchInputEnable(enable)
Set if touch input is allowed
| Name | Type | Description |
|---|---|---|
enable | boolean |
- Source
(static) setVibrateEnable(enable)
Set to allow vibration hardware if it exists
| Name | Type | Description |
|---|---|---|
enable | boolean |
- Source