Global

Members

# engineCollideObjects

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

# (constant) engineName

Name of engine
Source:

# engineObjects

Array containing all engine objects
Source:

# (constant) engineVersion

Version of engine
Source:

# (constant) FPS

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

# frame

Current update frame, used to calculate time
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, tileImageSource)

Start up LittleJS engine with your callback functions
Parameters:
Name Type 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 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()

Detroy and remove all objects that are not persistent or descendants of a persistent object
Source:

# engineObjectsUpdate()

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