game-loop
Simple utility class to create gameloops based on
requestAnimationFrame
, vendor variations or falling back on a 60 fpssetTimeout
loop. Ment to be used in the browser, with Browserify
Installation
npm install game-loop
Usage
var Loop = loop = ; loop; loop; loop // Frame 0 loop
Methods
.use([ callback ])
- Attach a callback to loop iterations.play()
- Start the loop.stop()
- Stop the loop.getFPS()
- Get frames-per-second rated based on last performed iteration
Properties
frame
- Current frame numberlastUpdate
- Timestamp registered after completing last iterationfps
- Last calculated framerate