update.js
update loop API for javascript apps
Live Example with Source
https://davidfig.github.io/update/
Installation
npm install yy-update
API Reference
Functions
- init([options])
must call init() before using Update
- registerPause(pause, resume)
register functions to call after Update pauses or resumes
- pauseGame()
pauses all updates
- resumeGame()
resumes all updates
- add(funct, [options])
adds a function to the update loop
- clear()
removes all updates and clears the percentage list
- remove(update)
removes an update from the loop
- update()
starts the update loop
init([options])
must call init() before using Update
Kind: global function
Param | Type | Description |
---|---|---|
[options] | object |
|
[options.Debug] | object |
pass Debug from github.com/davidfig/debug |
[options.count] | boolean | string |
show debug counts (can supply side for panel, e.g., 'topleft') |
[options.percent] | boolean | string |
show debug percentage |
[options.FPS] | boolean | string |
show debug FPS |
[options.onLoop] | function |
call at end of update loop |
registerPause(pause, resume)
register functions to call after Update pauses or resumes
Kind: global function
Param | Type |
---|---|
pause | function |
resume | function |
pauseGame()
pauses all updates
resumeGame()
resumes all updates
add(funct, [options])
adds a function to the update loop
Kind: global function
Param | Type | Default | Description |
---|---|---|---|
funct | function |
||
[options] | object |
||
[options.time] | number |
0 |
in milliseconds to call this function |
[options.FPS] | number |
this replaces options.time and calls the function at the desired FPS | |
[options.once] | boolean |
false |
call only once and then remove from update queue |
[options.percent] | string |
name to track the percentage in the debug panel |
clear()
removes all updates and clears the percentage list
remove(update)
removes an update from the loop
Kind: global function
Param | Type | Description |
---|---|---|
update | object |
object returned by add() |
update()
starts the update loop
Kind: global function
Copyright (c) 2017 YOPEY YOPEY LLC - MIT License - Documented by jsdoc-to-markdown