Members
# (constant) engineName
Name of engine
# engineObjects
Array containing all engine objects
# engineObjectsCollide
Array containing only objects that are set to collide with other objects (for optimization)
# (constant) engineVersion
Version of engine
# frame
Current update frame, used to calculate time
# (constant) frameRate
Frames per second to update objects
- Default Value:
- 60
# paused
Is the game paused? Causes time and objects to not be updated.
# time
Current engine time since start in seconds, derived from frame
# (constant) timeDelta
How many seconds each frame lasts, engine uses a fixed time step
- Default Value:
- 1/60
# timeReal
Actual clock time since start in seconds (not affected by pause or frame rate clamping)
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 |
# 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 |
# engineObjectsDestroy()
Detroy and remove all objects that are not persistent or descendants of a persistent object
# engineObjectsUpdate()
Calls update on each engine object (recursively if child), removes destroyed objects, and updated time