Global

Members

# engineFontImage

Font Image Object - Draw text on a 2D canvas by using characters in an image
- 96 characters (from space to tilde) are stored in an image
- Uses a default 8x8 font if none is supplied
- You can also use fonts from the main tile sheet
Example
// use built in font
const font = new ImageFont;

// draw text
font.drawTextScreen("LittleJS\nHello World!", vec2(200, 50));

# (constant) engineName

Name of engine
Source:

# engineObjects

Array containing all engine objects
Source:

# engineObjectsCollide

Array containing only objects that are set to collide with other objects this frame (for optimization)
Source:

# (constant) engineVersion

Version of engine
Source:

# frame

Current update frame, used to calculate time
Source:

# (constant) frameRate

Frames per second to update objects
Default Value:
  • 60
Source:

# paused

Is the game paused? Causes time and objects to not be updated.
Source:

# time

Current engine time since start in seconds, derived from frame
Source:

# (constant) timeDelta

How many seconds each frame lasts, engine uses a fixed time step
Default Value:
  • 1/60
Source:

# timeReal

Actual clock time since start in seconds (not affected by pause or frame rate clamping)
Source:

Methods

# engineInit(gameInit, gameUpdate, gameUpdatePost, gameRender, gameRenderPost, tileImageSourceopt)

Start up LittleJS engine with your callback functions
Parameters:
Name Type Attributes Description
gameInit function Called once after the engine starts up, setup the game
gameUpdate function Called every frame at 60 frames per second, handle input and update the game state
gameUpdatePost function Called after physics and objects are updated, setup camera and prepare for render
gameRender function Called before objects are rendered, draw any background effects that appear behind objects
gameRenderPost function Called after objects are rendered, draw effects or hud that appear above all objects
tileImageSource String <optional>
Tile image to use, everything starts when the image is finished loading
Source:

# engineObjectsCallback(posopt, sizeopt, callbackFunctionopt, objectsopt)

Triggers a callback for each object within a given area
Parameters:
Name Type Attributes Default Description
pos Vector2 <optional>
Center of test area
size Number <optional>
Radius of circle if float, rectangle size if Vector2
callbackFunction function <optional>
Calls this function on every object that passes the test
objects Array <optional>
engineObjects List of objects to check
Source:

# engineObjectsDestroy()

Destroy and remove all objects
Source:

# engineObjectsUpdate()

Calls update on each engine object (recursively if child), removes destroyed objects, and updated time
Source: